How to tell if Garbage collector has run
4 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   vy_vy
Posted On:   Wednesday, November 13, 2002 06:26 AM

Is there a way to tell if garbage collector has ever run during the life time of an application?

Thanks,
Vani

Re: How to tell if Garbage collector has run

Posted By:   balaji_viswanathan  
Posted On:   Thursday, November 21, 2002 09:03 AM

You might want to look at the JVMPI interface. jvm profiler interface lets you have hooks for some events. i noticed that startgc and finishgc are two such events. you should be not only be able to count the number of times gc ran but also how much objects were freed every time from what sites etc.

Re: How to tell if Garbage collector has run

Posted By:   amit_anand  
Posted On:   Monday, November 18, 2002 02:05 PM

Try running your program with the -verbosegc option - you will see GC statements if the garbage collector runs

Re: How to tell if Garbage collector has run

Posted By:   Zac_Jacobson  
Posted On:   Wednesday, November 13, 2002 04:22 PM

I don't believe you can know this explicitly. You could call Runtime.freeMemory() once in a while, and if the number it returns ever goes up, you will know that the garbage collector has run. If the number never goes up, you will not know for sure that the garbage collector has not run.

You can ask the JVM to run the garbage collector, then you'll know that it ran: System.gc()

Re: How to tell if Garbage collector has run

Posted By:   Zac_Jacobson  
Posted On:   Wednesday, November 13, 2002 03:52 PM

I don't think you can explicitly discover that, but if you use Runtime.freeMemory() once in a while, and the number it returns is ever higher than the last time, the the garbage collector must have run. No guarantee that it didn't if the number isn't higher.

You can ask the garbage collector to run with System.gc().

About | Sitemap | Contact