recently i met a gc problem ,i used jmap to dump out the heap. But unfortunately it did not work properly;
i run jmap -histo 3916|more before dump ,the result is
num #instances #bytes class name
----------------------------------------------
1: 1784198 733117168 [C
2: 12210014 390720448 java.util.concurrent.ConcurrentHashMap$Node
3: 11908601 285806424 java.lang.Long
4: 11884602 285230448 java.lang.Double
5: 545 86335608 [Ljava.util.concurrent.ConcurrentHashMap$Node;
6: 12405 65677584 [I
7: 1735496 41651904 java.lang.String
then i ran "jmap -dump:format=b,file=heap.bin 3916", and then i used eclipse MemoryAnalyzer to analyze heap.bin,which produced a histogram as below
Class Name | Objects | Shallow Heap | Retained Heap
-----------------------------------------------------------------------------------------
java.util.concurrent.ConcurrentHashMap$Node | 12,207,879 | 390,652,128 |
java.lang.Long | 11,889,204 | 285,340,896 |
java.lang.Double | 11,884,164 | 285,219,936 |
java.util.concurrent.ConcurrentHashMap$Node[]| 347 | 86,311,832 |
char[] | 1,659,912 | 50,128,128 |
java.lang.String | 1,659,062 | 39,817,488 |
-----------------------------------------------------------------------------------------
Analyzed the two result, i found that the objects in dump are all less than histo,and the Objects of char[] is much less, but why? does jmap trigger a minor gc when run "jmap -dump" command?
jmap
does not trigger GC unless you specify :live
option. Without this option the histogram includes unreachable objects.
However, Memory Analyzer by default removes unreachable objects while parsing a heap dump. Though it is possible to count unreachable objects with Memory Analyzer, too.