Skip to content

Latest commit

 

History

History
104 lines (70 loc) · 2.58 KB

HotSpot_JVM.asciidoc

File metadata and controls

104 lines (70 loc) · 2.58 KB

JVM OPTS & Commands

There are many different command line switches that can be used with Java. This section describes some of the more commonly used switches:

  • -Xms - Sets the initial heap size for when the JVM starts

  • -Xmx - Sets the maximum heap size

  • -Xmn - Sets the size of the Young Generation

  • -XX:PermSize - Sets the starting size of the Permanent Generation

  • -XX:MaxPermSize - Sets the maximum size of the Permanent Generation

Enable GC log
-verbose:gc -Xloggc:gc.log
-verbose:gc -Xloggc:gc.log -XX:+PrintGCDetails
-verbose:gc -Xloggc:gc.log -XX:+PrintGCDetails -XX:+PrintGCDateStamps
Enable heap dump
-XX:+HeapDumpOnOutOfMemoryError
Enable jconsole
  • jconsole monitor j2se app(including JMX MBean monitor)

-Dcom.sun.management.jmxremote -Dcom.sun.management.jmxremote.port=9010 -Dcom.sun.management.jmxremote.local.only=false -Dcom.sun.management.jmxremote.authenticate=false -Dcom.sun.management.jmxremote.ssl=false
  • jconsole monitor j2se app(Only monitor memory and threads)

-Dcom.sun.management.jmxremote
  • jconsole monitor JBoss 6 and previous version JBoss

-Djboss.platform.mbeanserver
Use jmap
  • print java heap summary

jmap -heap <PID>
  • generate heap dump(Linux 32)

jmap -dump:format=b,file=heap.hprof JAVA_PID
  • generate heap dump(Linux 64)

jmap -J-d64 -dump:format=b,file=heap.hprof JAVA_PID
  • generate heap dump(Windows)

jmap -dump:format=b,file=heap.hprof JAVA_PID