Gc questions

Godmar Back gback at cs.utah.edu
Mon Jan 24 14:07:27 PST 2000


> 
> 
> 1) How does kaffe handle making object once again reachable from
> finalize method ? Are there two gc phases - first for detecting
> unreachable objects and second scannning everything again to actually
> free object both unreachable and already finalized ?

Take a look at gc-incremental.c; unreachable objects that need finalization
are put on a finalizer list.  During a gc, the finalizer list is walked.
An object won't actually be freed until it's been finalized and become
unreachable again.  If an object scheduled for finalization becomes reachable 
before it's been finalized, it will still be finalized.

I guess the short answer is that the collector keeps track of object
scheduled for finalization and makes sure they're kept alive.  The second
part is that objects are only freed if their indeed unreachable.  The
third part is that each object gets finalized only once.
Somewhere in the JLS or on Sun's webpage there's a state graph showing
the states a Java object can be in.

> 
> 2) What piece of code/functions are responsible for
> Soft/Weak/PhantomReferences ? What I'm interested in most is how kaffe
> detects all references that needs to be cleared when given object is
> available for collection.
> 

Not implemented yet.

	- Godmar



More information about the kaffe mailing list