Java - Circular Garbage Collection
<p>A &lt;-> B &lt;-> C &lt;-> D &lt;-> A...</p>

<p>// A is firstNode, D is lastNode</p>

<pre><code>        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;
        }
</code></pre>

<p>That should send everything in between as candidates for garbage collection, I hope?</p>
