Java memory leak example..
Jul 11, 2003 in Java, JavaUsage
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; }