When the code reaches here, which 3 objects are GC?At line 6,i4.i refers to Island object and i2.i refers to island object,i3.i refers to island object.three objects(new Islands()) are already having object references(i2.i,i3.i,i4.i) refers to that.i2,i3,i4 are not objects.Those are object references.Then which three objects are eligible for GC here and how?Please help me.
Then which three objects are eligible for GC here and how?
I mean the three new Island-objects, not the references. And I don't think, that this is an example of island of isolation. i2,3,4 are all nulled so all of their member variables (i) don't have an object which they could reference. And no live thread can access these i2,3,4. So the three above are eligible for garbage collection.
thank you for correcting me by providing the link.
I was wrong, this IS an example of an island of isolation. Your nulling the "outer" islands. The member islands form an island of isolation, so GC can finalize the outer islands even though, there are references to them, but these are isolated.
I extended the code a bit, so it prints something:
Prints out: (VM dependent) after line 6before calling System.gc after calling gc "when the code reaches here"before calling System.gc Island 4 finalized Island 3 finalized Island 2 finalized after calling gc ready
I’ve looked at a lot of different solutions, and in my humble opinion Aspose is the way to go. Here’s the link: http://aspose.com