ClassLoader Leak test framework in Maven

Today I launch another weapon in the ongoing war on Classloader Leaks: The classloader-leak-test-framework. Admittedly, the framework itself is not new. The news is that in order to use it you no longer have to clone the Git repo, because it is now available as a Maven artifact through Maven Central.

If you want to confirm a suspected leak, just add


to your POM and create a test case that you believe would trigger the leak. (Make sure to check GitHub for the current version.)

Heap dump when leak detected

Another improvement to the test framework that I have not previously announced, is that the framework can now automatically create a heap dump when a ClassLoader leak is detected. This makes it even easier to track down the cause of the leak and determine the required countermeasures. To activate this feature add @Leaks(dumpHeapOnError = true) to your test method.

Test framework documentation

For further information on how to use the ClassLoader Leak test framework, see the projects space on GitHub.

  • Shankam

    Hello Mattias,
    Great post for novice like me. Can you help me listing down the steps on how can we use your test framework in a web app running on weblogic server?

  • Hi Shankam. The test framework is not intended for use inside a running Application Server. If you have problems in your running application, and you have not suspects that you want to use the test framework on, you can add the ClassLoader Leak Prevention library and see if it can avoid the problems for you. It will also log warnings for any potential leaks detected, which may be of help in tracking down the source.

    You can also follow my guide on how to acquire a heap dump and analyse it for leaks.