定位JVM内存泄漏常用命令和方法
1 ./jmap -histo:live 3559 | head -30 查看大对象,不过一般前几个都是字符数组和字节数组
2 ./jmap -dump:live,format=b,file=/opt/logs/rdrslogs/dump.hprof 3559
3 启动参数一定加verbose
4 Native Memory Tracking (NMT) 是Hotspot VM用来分析VM内部内存使用情况的一个功能。我们可以利用jcmd(jdk自带)这个工具来访问NMT的数据。
5 敲命令 jmap -heap pid
using thread-local object allocation. Garbage-First (G1) GC with 2 thread(s) Heap Configuration: MinHeapFreeRatio = 40 MaxHeapFreeRatio = 70 MaxHeapSize = 3212836864 (3064.0MB) NewSize = 1363144 (1.2999954223632812MB) MaxNewSize = 1927282688 (1838.0MB) OldSize = 5452592 (5.1999969482421875MB) NewRatio = 2 SurvivorRatio = 8 MetaspaceSize = 536870912 (512.0MB) CompressedClassSpaceSize = 1073741824 (1024.0MB) MaxMetaspaceSize = 536870912 (512.0MB) G1HeapRegionSize = 1048576 (1.0MB) Heap Usage: G1 Heap: regions = 3064 capacity = 3212836864 (3064.0MB) used = 109591032 (104.51415252685547MB) free = 3103245832 (2959.4858474731445MB) 3.41103630962322% used G1 Young Generation: Eden Space: regions = 13 capacity = 1352663040 (1290.0MB) used = 13631488 (13.0MB) free = 1339031552 (1277.0MB) 1.0077519379844961% used Survivor Space: regions = 0 capacity = 0 (0.0MB) used = 0 (0.0MB) free = 0 (0.0MB) 0.0% used G1 Old Generation: regions = 92 capacity = 794820608 (758.0MB) used = 95959544 (91.51415252685547MB) free = 698861064 (666.4858474731445MB) 12.073107193516552% used
6 在开启了verbose的情况下 敲 jmap -clstats 7984