Randhir Ray
1 min readMar 2, 2018

Garbage Collection

When an object(say A) holds the reference to another object (say B)

Case 1: If object B’s reference is not being hold by any other variable in the program and we dereference object A, both the objects are eligible for garbage collection.

Case 2: If object B’s reference is being hold by any other variable in the program and we dereference object A, only object A is eligible for garbage collection