A friendly place for programming greenhorns!
Big Moose Saloon
Register / Login
Win a copy of
Java SE 8 for the Really Impatient
this week in the
Programmer Certification (SCJP/OCPJP)
Joined: May 23, 2001
May 23, 2001 23:17:00
I have read in some places that Garbage Collection in
cannot be forced. If this is true, what does System.gc() do?
What does Runtime.gc() do?
Joined: Apr 26, 2001
May 24, 2001 00:27:00
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
Joined: Mar 14, 2001
May 24, 2001 05:59:00
a small correction ... that would be Runtime.getRuntime().gc()
this is because gc() is not a static method
I agree. Here's the link:
subject: Garbage Collection
What does it mean to be eligible for gc?
Ask & Read Questions to Think More
All times are in JavaRanch time: GMT-6 in summer, GMT-7 in winter
| Powered by
Copyright © 1998-2014