Java Reference
In-Depth Information
Figure 5-5. Real-time heap display
This particular view shows the entire heap, which is periodically cycling between using
about 100 MB and 160 MB. jconsole can instead display only eden, or the survivor spaces,
or the old generation, or the permanent generation. If I'd selected eden as the region to chart,
it would have shown a similar pattern as eden fluctuated between 0 MB and 60 MB (and, as
you can guess, that means if I'd charted the old generation, it would have been essentially a
flat line at 100 MB).
For a scriptable solution, jstat is the tool of choice. jstat provides nine options to print
different information about the heap; jstat -options will provide the full list. One useful
option is -gcutil , which displays the time spent in GC as well as the percentage of each GC
area that is currently filled. Other options to jstat will display the GC sizes in terms of KB.
Remember that jstat takes an optional argument—the number of milliseconds to repeat the
command—so it can monitor over time the effect of GC in an application. Here is some
sample output repeated every second:
Search WWH ::




Custom Search