Details
-
Type: Improvement
-
Status: Closed
-
Resolution: Fixed
-
Affects Version/s: None
-
Fix Version/s: 1.1.3
-
Component/s: None
-
Labels:None
Description
The methods 'pop' and 'popSilently' from class 'FastStack' don't
nullify the reference to the object being popped, which prevents them
from being garbage collected.
So, instead of
public void popSilently()
{ this.pointer--; }public Object pop()
{ return this.stack[--this.pointer]; }I suggest this:
public void popSilently()
{ this.stack[--this.pointer] = null; }public Object pop()
{ final Object result = this.stack[--this.pointer]; this.stack[this.pointer] = null; return result; }Or is there a reason not to do so ? Setting to null does take more
time than doing nothing, but I think the added overhead is negligible
in face of a better garbage collection.
What do you think ?