|
Re: Java Object References
|
Posted: Mar 21, 2002 11:56 AM
|
|
> is there any way using which we can know about any > object that whether it has any active reference at > present or not, means qualify for gc or not. and if > so then can we get the information of its referrent?
If an object has no active reference, then you can't have a reference to it either, so the short answer is no. If you have a reference to it, then it is by definition not available for garbage collection. In other words, if you know enough about an object to ask the question is it available for GC, you probably have a reference to it so it isn't available for GC.
Maybe what you really are after is phantom references. Since 1.2, the JVM does support soft, weak, and phantom references. I'm not sure what you are trying to accomplish, but phantom references do allow you to be notified after object becomes available for garbage collection and before it is collected. More info about soft, weak, and phantom references is available here:
http://www.artima.com/insidejvm/ed2/ch09GarbageCollection14.html
|
|