What are the differences between weak reference, soft reference and phantom reference

Questions by Pavan Sangyam

Showing Answers 1 - 1 of 1 Answers

uncer

  • Jan 28th, 2010
 

The garbage collector might or might not reclaim a softly reachable object depending on how recently the object was created or accessed, but is required to clear all soft references before throwing an OutOfMemoryError. 

Weakly reachable objects are finalized some time after their weak references have been cleared. The only real difference between a soft reference and a weak reference is that the garbage collector uses algorithms to decide whether or not to reclaim a softly reachable object, but always reclaims a weakly reachable object.

Phantomly reachable objects are objects that have been finalized, but not reclaimed. The garbage collector will never clear a phantom reference. All phantom references must be explicitly cleared by the program.An excellent article explaining GC in Java is given

SHAHID KHAN ABBASI

  Was this answer useful?  Yes

Give your answer:

If you think the above answer is not correct, Please select a reason and add your answer below.

 

Related Answered Questions

 

Related Open Questions