aspose file tools*
The moose likes Java in General 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 Soft Skills this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "garbage collection" Watch "garbage collection" New topic
Author

garbage collection

Kris Decker
Ranch Hand

Joined: Jul 25, 2001
Posts: 38
Is there any way to FORCE garbage collection? I have put some calls to System.gc() in my code but (as I expected) the system sees the call but keeps chugging (no garbage collection)
Any help would be greatly appreciated.
Kris
Dale DeMott
Ranch Hand

Joined: Nov 02, 2000
Posts: 515
You can request the system to do a garbage collection, but there is no guarantee that it will happen. You can't force it.
Dale

------------------
By failing to prepare, you are preparing to fail.
Benjamin Franklin (1706 - 1790)


By failing to prepare, you are preparing to fail.<br />Benjamin Franklin (1706 - 1790)
Kris Decker
Ranch Hand

Joined: Jul 25, 2001
Posts: 38
Well, then that lends the question:
How do programs such as JProbe force garbage collection when you click on the garbage collection button?
Bosun Bello
Ranch Hand

Joined: Nov 06, 2000
Posts: 1510
I am not familiar with JProbe. But according to the JVM specs, GC can not be forced, It can only be suggested. You can ask the GC to execute, but it's up to the JVM when, and if at all, the GC runs.


------------------
Bosun
SCJP for the Java� 2 Platform


Bosun (SCJP, SCWCD)
So much trouble in the world -- Bob Marley
Peter Chase
Ranch Hand

Joined: Oct 30, 2001
Posts: 1970
Presumably, rather like a debugger, JProbe taps into interfaces (JPDA, JVMPI ...?) that let it do stuff inside the JVM that a normal program cannot. You wouldn't want to have a normal application attempt to use such interfaces.


Betty Rubble? Well, I would go with Betty... but I'd be thinking of Wilma.
Armand Aquino
Greenhorn

Joined: Jul 17, 2001
Posts: 22
Sometimes when you know you're done with the object, just set it to null. But still there is no guarantee that anything will force gc.
Dave Turner
Ranch Hand

Joined: Mar 13, 2001
Posts: 60
What is it that you are actually trying to achieve by running the garbage collector, there is most likely an easier and more reliable way than using the gc.
Dave
Originally posted by Kris Decker:
Is there any way to FORCE garbage collection? I have put some calls to System.gc() in my code but (as I expected) the system sees the call but keeps chugging (no garbage collection)
Any help would be greatly appreciated.
Kris

 
jQuery in Action, 2nd edition
 
subject: garbage collection