Hi ,
Is there any way that an application can know when an object created in its context is garbage collected.
I dont know if this is the right fourm to post this question.
Thanks
puru
-
Garbage Collection Question (7 messages)
- Posted by: puru kk
- Posted on: September 06 2003 12:21 EDT
Threaded Messages (7)
- Garbage Collection Question by Paul Strack on September 06 2003 12:41 EDT
- Garbage Collection Question by Pranav Soni on September 06 2003 14:54 EDT
- Re: Garbage Collection Question by Shekhar Gulati on November 15 2008 20:49 EST
- Re: Garbage Collection Question by Shekhar Gulati on November 15 2008 08:50 EST
- Garbage Collection Question by D S on September 08 2003 11:13 EDT
- fyi, Weak references, Soft references by Sean Sullivan on September 08 2003 16:32 EDT
- fyi, Weak references, Soft references by puru kk on September 09 2003 10:26 EDT
-
Garbage Collection Question[ Go to top ]
- Posted by: Paul Strack
- Posted on: September 06 2003 12:41 EDT
- in response to puru kk
You can use the finalize() method, which is (sometimes) invoked when the object is garbage collected. Unfortunately, this method is not guaranteed, so it not 100% accurate. -
Garbage Collection Question[ Go to top ]
- Posted by: Pranav Soni
- Posted on: September 06 2003 14:54 EDT
- in response to Paul Strack
There is no guarantee that the Object eligible for Garbage collection will be Garbage collected. But finalize() method is guaranted to be invoked once on the object being Garbage collected. -
Re: Garbage Collection Question[ Go to top ]
- Posted by: Shekhar Gulati
- Posted on: November 15 2008 20:49 EST
- in response to Paul Strack
-
Re: Garbage Collection Question[ Go to top ]
- Posted by: Shekhar Gulati
- Posted on: November 15 2008 20:50 EST
- in response to Shekhar Gulati
You can read about garbage collection at http://www.java4all.info/articles/corejava/garbage-collection-java.html -
Garbage Collection Question[ Go to top ]
- Posted by: D S
- Posted on: September 08 2003 11:13 EDT
- in response to puru kk
I think you can do this using PhantomReferences and ReferenceQueues, although it's not something I've done myself. I vaguely remember reading an article about it some time ago. -
fyi, Weak references, Soft references[ Go to top ]
- Posted by: Sean Sullivan
- Posted on: September 08 2003 16:32 EDT
- in response to puru kk
Weak references and soft references:
A program may request to be notified of changes in an object's reachability by registering an appropriate reference object with a reference queue at the time the reference object is created. Some time after the garbage collector determines that the reachability of the referent has changed to the value corresponding to the type of the reference, it will add the reference to the associated queue.
package: java.lang.ref
http://java.sun.com/products/jdk/1.2/docs/api/java/lang/ref/package-summary.html -
fyi, Weak references, Soft references[ Go to top ]
- Posted by: puru kk
- Posted on: September 09 2003 10:26 EDT
- in response to Sean Sullivan
Thanks a lot for all your replies. They were helpful, I'll do some experimentation based on the suggestions, and keep the group posted.
Thanks
Puru