File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Java in General and the fly likes help with MemoryPoolMXBeans Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark "help with MemoryPoolMXBeans" Watch "help with MemoryPoolMXBeans" New topic

help with MemoryPoolMXBeans

Brian Cole
Ranch Hand

Joined: Sep 20, 2005
Posts: 878
A sun developer article suggests code similar to this

Running this (hotspot) might show:

Memory type=Non-heap memory, Pool name=Code Cache,
Memory usage=init = 163840(160K) used = 1724608(1684K) committed = 1736704(1696K) max = 33554432(32768K)

Memory type=Heap memory, Pool name=Eden Space,
Memory usage=init = 524288(512K) used = 287792(281K) committed = 524288(512K) max = 71565312(69888K)

Memory type=Heap memory, Pool name=Survivor Space,
Memory usage=init = 65536(64K) used = 65536(64K) committed = 65536(64K) max = 8912896(8704K)

Memory type=Heap memory, Pool name=Tenured Gen,
Memory usage=init = 1441792(1408K) used = 1735896(1695K) committed = 2093056(2044K) max = 715915264(699136K)

Memory type=Non-heap memory, Pool name=Perm Gen,
Memory usage=init = 8388608(8192K) used = 11914720(11635K) committed = 12058624(11776K) max = 67108864(65536K)

Ok, this code is simple enough, but it doesn't quite let me do
what I want, which is to determine peak total memory usage.

I could sum all the p.getPeakUsage() values in a loop, but
that isn't likely to be accurate because if a bunch of objects
move from the Eden space to the Survivor space they will be
counted twice.

What am I missing here?
[ March 08, 2006: Message edited by: Brian Cole ]

bitguru blog
I agree. Here's the link:
subject: help with MemoryPoolMXBeans
jQuery in Action, 3rd edition