posted 21 years ago
in pop1(), only the index is being shifted - but there is a still a Strong reference to the object by an element of the array. This object can never be garbage collected until the array itself is eligible for GC - hence the leak.
In pop2(), the index is being modified - But, the element reference is set to null. Therefore, this array will not prevent this object from being GC'ed if there are no references to the object.