Is it possible to identify that object is collected by garbage collector or not in java?

Viewed 2043

i have read that object becomes eligible for garbage collection in following cases.

  1. All references of that object explicitly set to null.
  2. Object is created inside a block and reference goes out scope once control exit that block.
  3. Parent object set to null, if an object holds reference of another object and when you set container object's reference null, child or contained object automatically becomes eligible for garbage collection.

But is there anyway to identify that object which is eligible for garbage collection is collected by garbage collector?

2 Answers
Related