How do I garbage collect objects which have created instances of their inner classes?
<p>The Java garbage collector is failing to collect dead objects in a program I wrote, and I believe this is because the dead objects have created instances of their inner classes.</p>

<p>When I look at the instances of the inner class in Debug mode, after the creator should have been collected, I find a reference titled <code>this$0</code>, which points to the should-be-dead object.</p>

<p>Is there a way to prevent an <code>Outer.this</code> reference from being created by java in each instance of <code>Inner</code>? This field has no use in the program, and all it does is prevent garbage collection, quickly causing the heap to run out of memory. Moving <code>Inner</code> out of <code>Outer</code> is not an option because it has <code>public</code> data fields that should only be visible to <code>Outer</code>.</p>
