• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Times of Garbage Collector

 
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello,

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.
 
Ranch Hand
Posts: 180
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic