title: Automated way to find JUnit tests that leak memory
body: <p>The root of our problem is Singletons.  But Singletons are hard to break and in the meantime we have a lot of unit tests that use Singletons without being careful to completely clear them in the tearDown() method.  I figure that a good way to detect tests like these is to look for memory leaks.  If the memory used after tearDown() and System.gc() is more than when the test started, either the test leaked or more classes were loaded by the classloader.  Is there any way to automatically detect this sort of problem?</p>