2 ms·
If you don't nullify every reference, then the instance really should not be garbage collected, as it is not garbage yet. You should rather consider your applic
by vetinari 17y ago
If you don't nullify every reference, then the instance really should not be garbage collected, as it is not garbage yet. You should rather consider your application, where you are storing references and whether it is really needed (often better strategy is to make clone of the instance and treat it as disposable).
Modern garbage collectors traverse the object graph and dispose everything, that is not in the graph - meaning, that closed chain of object with circular references is not a problem - they will get gc'ed.
Accessing null reference does not give NullPointerException, ever. Dereferencing it does.