programmatic query of time spent doing GC

John Coomes John.Coomes at sun.com
Wed Jun 17 11:29:44 PDT 2009


Mario Mendez-Lojo (marioml at ices.utexas.edu) wrote:
> First of all, thank you all for your amazing response to previous questions!
> 
> I have a question: I want to programmatically measure the time spent by the JVM 
> in the *application* I'm running - i.e., I would like to substract any time 
> spent in garbage collection. I already maximized the heap in order to avoid GC, 
> but there is still some GC activity.
> 
> Is there any programmatic way of figuring out what that time is? I can always 
> verbose the GC statistics, and do the calculations manually, but is obviously 
> more painful.

There is java.lang.management.GarbageCollectorMXBean:

	http://java.sun.com/javase/6/docs/api/java/lang/management/GarbageCollectorMXBean.html

-John




More information about the hotspot-dev mailing list