aspose file tools*
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Garbage Collection Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "Garbage Collection" Watch "Garbage Collection" New topic
Author

Garbage Collection

Sharada Kumaran
Greenhorn

Joined: May 23, 2001
Posts: 29
I have read in some places that Garbage Collection in java cannot be forced. If this is true, what does System.gc() do?
What does Runtime.gc() do?

Sharon
Jonathan Jones
Greenhorn

Joined: Apr 26, 2001
Posts: 6
System.gc() or Runtime.gc() simply make a tentative call to run the garbage collector. They do not force at all the garbage collector to be run. Thus the garbage collector may or may not run, but you can never be sure
Regards
Jonathan
Samith Nambiar
Ranch Hand

Joined: Mar 14, 2001
Posts: 147
hi
a small correction ... that would be Runtime.getRuntime().gc()
this is because gc() is not a static method
Samith.P.Nambiar
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Garbage Collection