Reputation: 711
I have very simple question but the answer is still not clear. If i have class Person and inside class Person there is one attribute which references to other object(ex: Account). If Person object is eligible for GC so either that attribute will be eligible to be cleaned up?
Upvotes: 0
Views: 60
Reputation: 5068
Yes, as soon as the instance of Person is removed by the GC, the instance of Account will also get eligible if no other reference to it exists.
Upvotes: 0
Reputation: 420991
If Person object is eligible for GC so either that attribute will be eligible to be cleaned up?
Yes, unless some other object has a reference to that very account object.
Basically any object that can't be referred to in the future is eligible for GC.
Upvotes: 2