Java - Circular Garbage Collection
- by aloh
A <- B <- C <- D <- A...
// A is firstNode, D is lastNode
if ( length == 1 )
{
firstNode = null;
lastNode = null;
firstNode.next = null;
firstNode.prev = null;
}
else
{
Node secondNode = firstNode.next;
Node secondToLast = lastNode.prev;
firstNode.next = null;
firstNode.prev = null;
lastNode.next = null;
lastNode.prev = null;
secondNode.prev = null;
secondToLast.next = null;
firstNode = null;
lastNode = null;
}
That should send everything in between as candidates for garbage collection, I hope?