This page contains an archived post to the Design Forum (formerly called the Flexible Java Forum) made prior to February 25, 2002.
If you wish to participate in discussions, please visit the new
Finalization & GC
Posted by S.Prakash on July 26, 1999 at 7:24 PM
According what I have studied, setting the variable to null will "mark "
the object for finalization. And when the GC runs( VM dependent)
it will call the finalization of objects and only then your objects
are removed from memory. Hope it throws light on your doubts.
> If I know that will no longer be using an object, does the
> setting of member variable references to null faciliate
> garbage collection in any way? For example if I know that I am
> done with Object A and A implements a dispose() method that
> "cleans up" or sets all references to null, does this impact
> garbage collection in any way? Based upon my reading I would
> think it would be difficult, if not impossible, to know if this
> really has any impact on GC - since each VM may implement GC