Author: techfox9
Java memory leak example..
Friday, July 11th, 2003 @ 12:32 am
From “Java 2 Certification Study Guide” ..
Incorrect construct, produces a memory leak, otherwise known as memory “loitering”:
public Object pop() { return storage[index--]; }
The correct way:
public Object pop() { Object rv = storage[index]; storage[index--] = null; return rv; }