A quick question about the Java Runtime Garbage Collector.
Take this scenario:
Two Objects both hold a reference to the other.
No other Objects hold any reference to these Objects.
The Objects are not doing anything – they’re not Runnables, if they are their threads have ended.
Would the Garbage Collector collect these objects, because I’m using these Objects in massive amounts and ‘disposing’ of them by cutting references… but are they really being disposed?
Yes, the elements are eligible for collection. See:
What are the roots?
Whether they will be collected or not is up to the garbage collector.