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”:
[java]
public Object pop() {
return storage[index–];
}
[/java]
The correct way:
[java]
public Object pop() {
Object rv = storage[index];
storage[index–] = null;
return rv;
}
[/java]