jvm memory tool

jps (JVM Process Status Tool)

Used to check progress id/ start path/ start argument.
If remote machine running jstat, jps can query remote vm progress.
define:
jps [-q] [-mlvV] [<hostid>]

  • -m arguments that input into main
  • -v arguments that input into jvm
  • -l main class package path or jar file path

jmap( Memory Map for Java)

mapping jvm’s object/ reference
define:
jmap [option] <pid>

a b
-heap heat info
-histo[:live] default in live
-dump
live dump only live objects
format=b binary format
file=path dump heap to
-permstat permanent generation
-finalizerinfo object waiting finaliz
-F force all object dump or histo
1
2
3
jmap -histo 20836
jmap -permstat 20836
jmap -dump:live,format=b,file=data.hprof 20836

jhat(JVM Heap Analysis Tool)

offline dump file analysis, check memory info.
But Visual interface is much more better like jvisualvm jconsole

jinfo(Configuration Info for Java)

print or modify java progress’s options(flag). print system properties

1
2
jinfo -sysprops 20836
jinfo -flags 20836

jstat(JVM statistics Monitoring Tool)

monitor jvm grogress’s resource and performence
define:
jstat -<option> [-t] [-h<lines>] <vmid> [<interval> [<count>]]

a b
-class class’ mateinfo in jvm
-compiler compiler info in jvm
-gc current jvm global info
-gccapacity similar as above
-gccause reason cause gc option
-gcnew youny generation (eden + servivor)
-gcnewcapacity
-gcold old generation
-gcoldcapacity old capacity
-gcpermcapacity perm capacity
1.6 in method space
1.8 in true memory
-gcutil static class ?
-printcompilation compile summary
a b
S0 年轻代中第一个survivor(幸存区)已使用的占当前容量百分比
S1 年轻代中第二个survivor(幸存区)已使用的占当前容量百分比
S0C 年轻代中第一个survivor(幸存区)的容量 (字节)
S1C 年轻代中第二个survivor(幸存区)的容量 (字节)
S0U 年轻代中第一个survivor(幸存区)目前已使用空间 (字节)
S1U 年轻代中第二个survivor(幸存区)目前已使用空间 (字节)
S0CMX 年轻代中第一个survivor(幸存区)的最大容量 (字节)
S1CMX 年轻代中第二个survivor(幸存区)的最大容量 (字节)
a b
E 年轻代中Eden(伊甸园)已使用的占当前容量百分比
EC 年轻代中Eden(伊甸园)的容量 (字节)
EU 年轻代中Eden(伊甸园)目前已使用空间 (字节)
NGCMN 年轻代(young)中初始化(最小)的大小 (字节)
NGCMX 年轻代(young)的最大容量 (字节)
NGC 年轻代(young)中当前的容量 (字节)
a b
O old代已使用的占当前容量百分比
OC Old代的容量 (字节)
OU Old代目前已使用空间 (字节)
OGCMN old代中初始化(最小)的大小 (字节)
OGCMX old代的最大容量 (字节)
OGC old代当前新生成的容量 (字节)
a b
P perm代已使用的占当前容量百分比
PC Perm(持久代)的容量 (字节)
PU Perm(持久代)目前已使用空间 (字节)
PGCMN perm代中初始化(最小)的大小 (字节)
PGCMX perm代的最大容量 (字节)
PGC perm代当前新生成的容量 (字节)
a b
YGC 从应用程序启动到采样时年轻代中gc次数
YGCT 从应用程序启动到采样时年轻代中gc所用时间(s)
FGC 从应用程序启动到采样时old代(全gc)gc次数
FGCT 从应用程序启动到采样时old代(全gc)gc所用时间(s)
GCT 从应用程序启动到采样时gc用的总时间(s)
DSS 当前需要survivor(幸存区)的容量 (字节)(Eden区已满)
TT 持有次数限制
MTT 最大持有次数限制

Troubleshooting

Local Applications Cannot Be Monitored (Error Dialog On Startup)
Description: An error dialog saying that local applications cannot be monitored
is shown immediately after VisualVM startup. Locally running Java applications
are displayed as (pid ###).

Resolution: This can happen on Windows systems if the username contains capitalized letters.
In this case, username is UserName but the jvmstat directory created by JDK is %TMP%\hsperfdata_username.
To workaround the problem, exit all Java applications, delete the %TMP%\hsperfdata_username directory
and create new %TMP%\hsperfdata_UserName directory.

In windows platform if jconsole.exe interface, the local vm disenable, check user name, and directory name:

1
2
3
4
# If user name is Administrator
C:\Users\Administrator\AppData\Local\Temp\hsperfdata_administrator
# change to
C:\Users\Administrator\AppData\Local\Temp\hsperfdata_Administrator

https://visualvm.github.io/troubleshooting.html#jpswin2

jstack(Stack Trace for Java)

print specific progress’s or remote jvm’s stack info

http://blog.sina.com.cn/s/blog_b0e3dfe30102wfl5.html

http://www.bubuko.com/infodetail-792105.html

https://www.cnblogs.com/lishijia/p/5897236.html

http://www.talkwithtrend.com/Article/161055

https://www.ibm.com/developerworks/cn/java/j-lo-JVMGarbageCollection/

https://www.ibm.com/developerworks/cn/java/l-JavaMemoryLeak/