The following example exists content leaks (or unconscious object holds, unintentional object ion). // Can u spot the "memory leak" public class Stack {private Ojbect [] elements;? Private int size = 0; public Stack (int initialCapacity) {this.elements = new Object [initialCapacity];} public void push (Object e) {ENSURECAPACITY (); ELEMENTS [SIZE ] = E;} public object pop () {if (size == 0) throw new emptystackedException (); return elements [- size];} / *** ensure Space for at least one more element, roughly doubling * the capacity each time the array needs to grow * / private void ensureCapacity () {if (elements.length == size) {Object [] oldElements = elements;. elements = new Object [2 * Elements.length 1]; System.ArrayCopy (Oldelements, 0, Elements, 0, size);}} Eliminate content leaks, only need to change the POP () method. Public Object Pop () {if (size == 0) throw new EmptyStackException (); object result = elements [- size]; elements [size] = null; return result;} As long as a class manages its memory, program The staff should be alert to memory leaks. Once an element is released, any object reference contained in this element should be emptied. Another common source of memory leaks is a cache, so you have to use a thread to periodically clear or use the cache object that is used at the time of joining. In the 1.4 release, you can use the REVMOVEELDESTRY method of java.util.linkedHashMap to implement the post-up. If a continuous running Java application is getting slower, consider whether to check the memory leak problem. The book is said to check the software that the memory leak is collectively referred to by Heap Profiler. I retrieve two http://sourceforge.net/projects/simpleprofiler and http://www.manageability.org/blog/stuff/open-source-profilers-for -java, there will be a chance to study well. I don't know if I read this article, can I recommend a few good tool software?