- jps 虚拟机进程状况工具
查看虚拟机进程
jps
24849 Jps
24119 JvmDemoApplication
查看虚拟机进程 有类路径
jps -l
24119 com.example.JvmDemoApplication
24888 sun.tools.jps.Jps
查看虚拟机进程 jvm启动参数
jps -v
24119 JvmDemoApplication -agentlib:jdwp=transport=dt_socket,address=127.0.0.1:52597,suspend=y,server=n -XX:TieredStopAtLevel=1 -Xverify:none -Dspring.output.ansi.enabled=always -Dcom.sun.management.jmxremote -Dspring.jmx.enabled=true -Dspring.liveBeansView.mbeanDomain -Dspring.application.admin.enabled=true -javaagent:/Users/baidu/Library/Caches/IntelliJIdea2019.2/captureAgent/debugger-agent.jar -Dfile.encoding=UTF-8
查看虚拟机进程 省略主类名称
jps -q
22640
22560
24962
22581
24118
22550
24119
23420
查看虚拟机进程 传递给main 函数的参数
jps -m
24119 JvmDemoApplication
查看虚拟机进程 过滤
jps -m | grep JvmDemoApplication
- jstat 虚拟机统计信息监控工具
每1秒执行一次 执行10次
jstat -gcutil 22442 1000 10
监视类装载 卸载数量 总空间以及类装载所耗费的时间
jstat -class 19852
Loaded Bytes Unloaded Bytes Time
6284 11417.7 0 0.0 5.14
监视Java堆状况,包括eden区 两个survivor 老年代 永久代 已用空间 gc时间
jstat -gc 19852
S0C S1C S0U S1U EC EU OC OU MC MU CCSC CCSU YGC YGCT FGC FGCT GCT
1024.0 1024.0 0.0 480.7 8256.0 1311.1 20480.0 11421.2 34048.0 32236.6 4608.0 4178.4 49 0.199 1 0.051 0.250
与-gc相同 但输出内容为使用总空间占比
jstat -gcutil 22442
S0 S1 E O M CCS YGC YGCT FGC FGCT GCT
58.57 0.00 35.79 51.70 94.45 91.94 46 0.190 1 0.029 0.218
与-gcutil 相同 但是会额外输出上次gc发生的原因
jstat -gccause 22442
S0 S1 E O M CCS YGC YGCT FGC FGCT GCT LGCC GCC
0.00 76.81 34.42 52.46 94.77 92.37 47 0.196 1 0.029 0.225 Allocation Failure No GC
监视新生代
jstat -gcnew 22442
S0C S1C S0U S1U TT MTT DSS EC EU YGC YGCT
1024.0 1024.0 599.7 0.0 2 15 512.0 8256.0 3120.4 46 0.190
监视新生代 最大使用情况
jstat -gcnew 22442
NGCMN NGCMX NGC S0CMX S0C S1CMX S1C ECMX EC YGC FGC
10240.0 156992.0 10304.0 15680.0 1024.0 15680.0 1024.0 125632.0 8256.0 47 1
- jinfo java 配置信息工具
查看是否使用类 serial gc收集器
jinfo -flag UseSerialGC 24902
-XX:-UseSerialGC
查看全部信息
jinfo -flags 24902
Attaching to process ID 24902, please wait...
Debugger attached successfully.
Server compiler detected.
JVM version is 25.181-b13
Non-default VM flags: -XX:CICompilerCount=2 -XX:InitialHeapSize=31457280 -XX:MaxHeapSize=482344960 -XX:MaxNewSize=160759808 -XX:MinHeapDeltaBytes=196608 -XX:NewSize=10485760 -XX:OldSize=20971520 -XX:+UseCompressedClassPointers -XX:+UseCompressedOops
Command line:
- jmap java 内存映射工具
手动执行gc
jmap -histo:live pid
jmap -dump:live,file=dump_001.bin PID
然后删掉dump_001.bin文件
导出堆信息到文件b 格式为byte
jmap -dump:format=b,file=/root/b.bin 28806
Dumping heap to /root/b1.bin ...
Heap dump file created
显示堆中对象统计信息
jmap -histo 2483
pid 类数量 实例数
2483: 1 16 sun.reflect.generics.tree.VoidDescriptor
2484: 1 16 sun.security.provider.NativePRNG
2485: 1 16 sun.security.util.AlgorithmDecomposer
2486: 1 16 sun.security.util.DisabledAlgorithmConstraints$Constraints
2487: 1 16 sun.util.calendar.Gregorian
2488: 1 16 sun.util.locale.provider.AuxLocaleProviderAdapter$NullProvider
2489: 1 16 sun.util.locale.provider.CalendarDataUtility$CalendarWeekParameterGetter
2490: 1 16 sun.util.locale.provider.SPILocaleProviderAdapter
2491: 1 16 sun.util.locale.provider.TimeZoneNameUtility$TimeZoneNameGetter
2492: 1 16 sun.util.resources.LocaleData
2493: 1 16 sun.util.resources.LocaleData$LocaleDataResourceBundleControl
Total 251635 14990856
查看堆详细信息 具体回收器 参数配置 分代状况
(jstat -gc pid ,jstat -gcutil pid 打印简略信息)
jmap -heap 28806
Attaching to process ID 28806, please wait...
Debugger attached successfully.
Server compiler detected.
JVM version is 25.181-b13
using thread-local object allocation.
Mark Sweep Compact GC
Heap Configuration:
MinHeapFreeRatio = 40
MaxHeapFreeRatio = 70
MaxHeapSize = 482344960 (460.0MB)
NewSize = 10485760 (10.0MB)
MaxNewSize = 160759808 (153.3125MB)
OldSize = 20971520 (20.0MB)
NewRatio = 2
SurvivorRatio = 8
MetaspaceSize = 21807104 (20.796875MB)
CompressedClassSpaceSize = 1073741824 (1024.0MB)
MaxMetaspaceSize = 17592186044415 MB
G1HeapRegionSize = 0 (0.0MB)
Heap Usage:
#新生代内存使用情况 一个eden区域 + 一个Survivor区域
New Generation (Eden + 1 Survivor Space):
capacity = 9502720 (9.0625MB) 容量
used = 4443024 (4.2371978759765625MB) 已使用
free = 5059696 (4.8253021240234375MB) 空闲
46.75528690732759% used 使用百分比
# eden区域
Eden Space:
capacity = 8454144 (8.0625MB)
used = 3649592 (3.4805221557617188MB)
free = 4804552 (4.581977844238281MB)
43.16926704820737% used
# from space 区域
From Space:
capacity = 1048576 (1.0MB)
used = 793432 (0.7566757202148438MB)
free = 255144 (0.24332427978515625MB)
75.66757202148438% used
# to space 区域
To Space:
capacity = 1048576 (1.0MB)
used = 0 (0.0MB)
free = 1048576 (1.0MB)
0.0% used
#老年代区域
tenured generation:
capacity = 20971520 (20.0MB)
used = 10996744 (10.487312316894531MB)
free = 9974776 (9.512687683105469MB)
52.436561584472656% used
11617 interned Strings occupying 1013400 bytes.
网友评论