MinhHoang
MinhHoang

Reputation: 711

Making object eligible to be cleaned up

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

Answers (2)

didi_X8
didi_X8

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

aioobe
aioobe

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

Related Questions