...
Reference nulling to "help the garbage collector" is not necessary at all. In fact, it just adds clutter to the code and may introduce more bugs. Assigning null
to local variables is also not very useful as the Java Just-In-Time compiler (JIT) can equivalently do a liveness analysis. A related bad practice is to use a finalizer to null
out references, thereby befriending causing a huge performance hit.
Code Block | ||
---|---|---|
| ||
int[] buffer = new int[100]; doSomething(buffer); buffer = null // no need for explicitly assigning null |
...