Creating a memory leak with Java

Actually, there are many ways to create a memory leak with Java.

Currently, I suppose there are two mainly thinking methods.


Creating many long-running threads (maybe using ThreadPool)

The Thread loads a class via ClassLoader

The class allocate a large chunk  of memory, store a strong reference to its static field

Class Leak is a common memory leak problem and it usually depends on the JVM


create listeners and do nothing

the listener will cause leak

Here is a link to this question: