Skip to content

Instantly share code, notes, and snippets.

@dacr
Last active April 2, 2023 10:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dacr/9b03fa139618c7e579ff2e6c75048e92 to your computer and use it in GitHub Desktop.
Save dacr/9b03fa139618c7e579ff2e6c75048e92 to your computer and use it in GitHub Desktop.
jvm cheat sheet / published by https://github.com/dacr/code-examples-manager #12adcc40-b47b-48dc-9ca6-f4f3ba3df9d8/6e877c962827e60f7dd6ebf17a2e2f2cd3ed07de

JVM cheat sheets

settings and chosen defaults

java -XshowSettings -version
java -XshowSettings:vm --version

Live monitoring

jps
jstack -e -l 7 > jstack-$(date -u +"%Y-%m-%dT%H:%M:%SZ")
jstat -gc 7 2000

flags with default values

java -XX:+UnlockDiagnosticVMOptions -XX:+PrintFlagsFinal -version

Memory

Use showSettings:vm to display JVM decisions :

java -XshowSettings:vm -version
java -Xms1500m -Xmx1600m -XshowSettings:vm -version
java -XX:MinRAMPercentage=50.0 -XX:MaxRAMPercentage=85.0 -XshowSettings:vm -version

Dump/stats mémoire :

jmap -histo 7
jmap -dump:live,format=b,file=heap.bin 7

garbage gc monitoring

JVM <=8

java -verbose:gc -XX:+PrintGC -XX:+PrintGCDetails

JVM >8

java -Xlog:gc*
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment