Object References
1 posts in topic
Flat View  Flat View

Posted By:   Dale_Herrig
Posted On:   Wednesday, June 13, 2001 10:41 AM

Is there a way to determine at runtime
the number of references a given object
has. For example, if I determined that
an object has only one reference to
it, I would set it equal to null so
it would be garbage collected.

Re: Object References

Posted By:   John_Mitchell  
Posted On:   Sunday, June 17, 2001 02:50 PM

I'm confused by your question. If there are no more references to an object then, by definition, any previous references to it are, in essence, already null.

Anyways, the answer to the general question of how figuring out how many references exist that refer to a specific object is... No, you can't figure that out in the general case in pure Java.

Note that if you only care about classes/objects which you create then you can always wrap your actual objects but that introduces its own problems.

About | Sitemap | Contact