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
-verbose:gc -Xloggc:gc.log -verbose:gc -Xloggc:gc.log -XX:+PrintGCDetails -verbose:gc -Xloggc:gc.log -XX:+PrintGCDetails -XX:+PrintGCDateStamps
-
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
-
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
-
JVM OPT: http://www.oracle.com/technetwork/java/javase/tech/vmoptions-jsp-140102.html
-
Solving common Java EE performance problems: http://www.javaworld.com/javaworld/jw-06-2006/jw-0619-tuning.html
-
Java® Virtual Machine Specification: http://docs.oracle.com/javase/specs/jvms/se7/html/
-
Java Garbage Collection Tutorial: http://www.oracle.com/webfolder/technetwork/tutorials/obe/java/gc01/index.html
-
Tuning JVM: http://www.oracle.com/webfolder/technetwork/tutorials/obe/java/gc01/index.html