Java Reference
In-Depth Information
Including the live option in jmap will force a full GC to occur before the heap is dumped.
That is the default for jcmd , though if for some reason you want those other (dead) objects
included, you can specify -all at the end of the jcmd command line.
Either command creates a file named heap_dump.hprof in the given directory; a number of
tools can then be used to open that file. Three of the most common are:
This is the original heap analyzer tool; it reads the heap dump and runs a small HTTP
server that lets you look at the dump through a series of web page links.
The monitor tab of jvisualvm can take a heap dump from a running program or open a
previously produced heap dump. From there you can browse through the heap, examin-
ing the largest retained objects and executing arbitrary queries against the heap.
The open source EclipseLink Memory Analyzer Tool ( mat ) can load one or more heap
dumps and perform analysis on them. It can produce reports that suggest where problems
are likely to be found, and it too can be used to browse through the heap and execute
SQL-like queries into the heap.
The first-pass analysis of a heap generally involves retained memory. The retained memory
of an object is the amount of memory that would be freed if the object itself were eligible to
be collected. In Figure 7-1 , the retained memory of the String Trio object includes the
memory occupied by that object as well as the memory occupied by the Sally and David ob-
jects. It does not include the memory used by the Michael object, since that object has anoth-
er reference and won't be eligible for GC if the String Trio is freed.
Search WWH ::

Custom Search