if i run Java with the option -verbose:gc I'll see when the gc works and the time it spends to perform the gc Like
[GC 325407K->83000K(776768K), 0.2300771 secs]
Is there a way to have the sum of the times used by GC in all its work? So I vould like to have a method that return just the sum of all the times printed?
Is it possible to know it in run time? I would like to print that time in an other format using a specific class.
In Java 5 and 6 there is something that might be just what you are looking for in the java.lang.management package, called GarbageCollectorMXBean (the getCollectionTime()) method.
These beans have a small learning curve if you have never used MX beans before but they can come in pretty handy.
Hope this helps.
- Chris Stehno, SCPJ
WHAT is your favorite color? Blue, no yellow, ahhhhhhh! Tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop