Skip to content

Instantly share code, notes, and snippets.

@neomatrix369
Last active July 18, 2023 22:49
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save neomatrix369/1ec4211820aef02da43fc0dc24279d00 to your computer and use it in GitHub Desktop.
Save neomatrix369/1ec4211820aef02da43fc0dc24279d00 to your computer and use it in GitHub Desktop.
Collection of HotSpot JVM flags for various purposes (mainly performance related)

Minimum JVM Flags

  • https://gist.github.com/sushanthmangalore/69871cbc87c97cbca67a130469fdee90
  • Guide to the Most Important JVM Parameters
  • Minimum flags to record GC logs (plus enabling safepoint stats)
    • Java 8
      -Xloggc:/path/to/gc.log    # <Location to write your GC log to>
      -XX:LogFile=<Location to write your Safepoint log to>
      -XX:+UseGCLogFileRotation 
      -XX:NumberOfGCLogFiles=< number of log files > 
      -XX:GCLogFileSize=< file size >[ unit ]
      -XX:+UnlockDiagnosticVMOptions
      -XX:+PrintGCDetails
      -XX:+PrintTenuringDistribution
      -XX:+PrintGCCause
      -XX:+PrintGCApplicationStoppedTime
      -XX:+PrintGCDateStamps
      -XX:+PrintGCTimeStamps   
      -XX:+PrintSafepointStatistics
      -XX:+LogVMOutput
      -XX:+HeapDumpOnOutOfMemoryError
      -XX:HeapDumpPath=./java_pid<pid>.hprof
      -XX:+CMSClassUnloadingEnabled       ### Pre-Java-8
      -XX:+UseGCOverheadLimit
      # Some more, check before using
      -XX:OnOutOfMemoryError="< cmd args >;< cmd args >" 
    
    • Java 11 and above
      -Xlog:gc=[warning|debug|error]:file=/path/to/gc.log:time,uptime,level,tags:filecoint=[n],filesize=[n]m
      -XX:+UnlockDiagnosticVMOptions
      -XX:LogFile=<Location to write your Safepoint log to>
      -XX:+LogVMOutput
      -XX:+HeapDumpOnOutOfMemoryError
      -XX:HeapDumpPath=./java_pid-%p.hprof
      -XX:+UseGCOverheadLimit
      -XX:FlightRecorderOptions=stackdepth=[nn]
    

See java command, arguments/parameters for Java 9 to find equivalents for Java 9 flags and java command, arguments/parameters for Java 11 for Java 11 flags.

Performance related JVM Flags

General/Misc

JIT

Java

Scala

Webserver

About author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment