JPS命令常用来查看linux服务器上的JVM的实例
-l:输出这个application的main class的full package name,或者main class的jar file路径
jps -l
3002 /opt/j2sdk1.5.0/demo/jfc/Java2D/Java2Demo.JAR
2857 sun.tools.jstatd.jstatd
-v: 输出JVM的arguments
22228 Jps -Denv.class.path=.:/Library/Java/JavaVirtualMachines/jdk1.8.0_101.jdk/Contents/Home/lib/ -Dapplication.home=/Library/Java/JavaVirtualMachines/jdk1.8.0_101.jdk/Contents/Home -Xms8m
22133 AppMain -Dmaven.home=/Applications/IntelliJ IDEA.app/Contents/plugins/maven/lib/maven3 -Dclassworlds.conf=/Applications/IntelliJ IDEA.app/Contents/plugins/maven/lib/maven3/bin/m2.conf -Didea.launcher.port=7532 -Didea.launcher.bin.path=/Applications/IntelliJ IDEA.app/Contents/bin -Dfile.encoding=UTF-8
15389 -Dfile.encoding=UTF-8 -XX:+UseConcMarkSweepGC -XX:SoftRefLRUPolicyMSPerMB=50 -ea -Dsun.io.useCanonCaches=false -Djava.net.preferIPv4Stack=true -XX:+HeapDumpOnOutOfMemoryError -XX:-OmitStackTraceInFastThrow -Xverify:none -XX:ErrorFile=/Users/java_error_in_idea_%p.log -XX:HeapDumpPath=/Users/java_error_in_idea.hprof -Xbootclasspath/a:../lib/boot.jar -Xms128m -Xmx2048m -XX:ReservedCodeCacheSize=240m -XX:+UseCompressedOops -XX:MaxPermSize=1024m -Djb.vmOptionsFile=/Users/Library/Preferences/IntelliJIdea2016.2/idea.vmoptions -Didea.java.redist=jdk-bundled -Didea.home.path=/Applications/IntelliJ IDEA.app/Contents -Didea.executable=idea -Didea.paths.selector=IntelliJIdea2016.2
当然也可以叠加使用
jps -lv
22133 com.intellij.rt.execution.application.AppMain -Dmaven.home=/Applications/IntelliJ IDEA.app/Contents/plugins/maven/lib/maven3 -Dclassworlds.conf=/Applications/IntelliJ IDEA.app/Contents/plugins/maven/lib/maven3/bin/m2.conf -Didea.launcher.port=7532 -Didea.launcher.bin.path=/Applications/IntelliJ IDEA.app/Contents/bin -Dfile.encoding=UTF-8
22235 sun.tools.jps.Jps -Denv.class.path=.:/Library/Java/JavaVirtualMachines/jdk1.8.0_101.jdk/Contents/Home/lib/ -Dapplication.home=/Library/Java/JavaVirtualMachines/jdk1.8.0_101.jdk/Contents/Home -Xms8m
jstat命令常用来监控某个jvm进程的内存占用问题
jstat -gc #pid
S0C S1C S0U S1U EC EU OC OU MC MU CCSC CCSU YGC YGCT FGC FGCT GCT
26752.0 26752.0 6877.0 0.0 214592.0 203198.4 535784.0 361816.3 259284.0 242894.3 36336.0 32603.2 600 9.602 56 51.876 61.478
jstat -gc #pid #interval 最后一个参数定义打印的间隔时间
S0C S1C S0U S1U EC EU OC OU MC MU CCSC CCSU YGC YGCT FGC FGCT GCT
26752.0 26752.0 0.0 9500.9 214592.0 66557.6 535784.0 361816.3 259284.0 242895.6 36336.0 32603.2 601 9.612 56 51.876 61.488
26752.0 26752.0 0.0 9500.9 214592.0 66716.9 535784.0 361816.3 259284.0 242895.6 36336.0 32603.2 601 9.612 56 51.876 61.488
26752.0 26752.0 0.0 9500.9 214592.0 66741.6 535784.0 361816.3 259284.0 242895.6 36336.0 32603.2 601 9.612 56 51.876 61.488
26752.0 26752.0 0.0 9500.9 214592.0 66751.4 535784.0 361816.3 259284.0 242895.6 36336.0 32603.2 601 9.612 56 51.876 61.488
26752.0 26752.0 0.0 9500.9 214592.0 66751.4 535784.0 361816.3 259284.0 242895.6 36336.0 32603.2 601 9.612 56 51.876 61.488
26752.0 26752.0 0.0 9500.9 214592.0 66751.4 535784.0 361816.3 259284.0 242895.6 36336.0 32603.2 601 9.612 56 51.876 61.488
jstat -class #pid 打印该进程加载了多少个类,以及这些类所占用的空间;未加载多少个class,以及占用的空间
Loaded Bytes Unloaded Bytes Time
49281 92067.2 3313 4221.3 33.73