I just read a blog post by Tor Norbye called How to Write a Memory Leak Unit Test. In it, he describes how code from the NetBeans team can be used to find memory leaks. It seems like it’s a more advanced, user-friendly way of doing what I described before. In particular, the chain of references preventing garbage collection is actually printed out during the test.
I definitely have to take a closer look at this. Thanks, Tor!