I'd like to measure memory allocation data from my java application, i.e. the sum of the size of all objects that were allocated. Since object allocation is done in young generation this seems to be the right place.
I know jconsole and I know the JMX beans but I just can't find the right variable... Right at the moment we are parsing the gc log output file but that's quite hard. Ideally we'd like to measure it via JMX...
How can I get this value?
Additional info after comment of Chadwick:
I want to know how much memory my application is using. It's quite a big software running in a JBoss Appserver. Every 4 weeks there is a new release of the software and we need to compare the memory consumption between old and new version. It's not enough to compare the current value of the old generation at a specific time. It's very useful to know how much more / or less memory gets allocated. Since many objects are getting collected in the young generation I need to measure it there.
In the meantime I have an estimate for this. I will post it as an answer.
Thanks, Marcel
You can monitor the Young Generation using the MemoryPool MBeans, and more specifically
http://java.sun.com/j2se/1.5.0/docs/api/java/lang/management/MemoryPoolMXBean.html
See the code examples at http://www.javadocexamples.com/java_source/com/sun/enterprise/admin/mbeans/jvm/MemoryReporter.java.html and http://www.java2s.com/Code/Java/Development-Class/ThisVerboseGCclassdemonstratesthecapabilitytogetthegarbagecollectionstatisticsandmemoryusageremotely.htm
If you are using the Sun JDK, you can simply enable GC logging with -verbose:gc -Xloggc:gc.log
and analyze the file. Or, if you need the total amount only occasionally, get the GCViewer by Tagtraum, which computes the number you are looking for.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With