URLClassLoader Memory Leak Java

2019-09-07 01:58发布

问题:

I have been going through a lot of URLClassLoader Memory leak solutions on the internet, but I haven't found any fully working code and precise solution. The closest to a solution I found was this

Any fully functional code or link to it, which uses WeakHashMap() or any other definite way of eliminating memory leak problem on multiple redeploys?

回答1:

just add the dependency of class loader leak preventer in your build path. maven dependency for this is :

<!-- For Classloader leak protection -->
        <dependency>
            <groupId>se.jiderhamn</groupId>
            <artifactId>classloader-leak-prevention</artifactId>
            <version>1.8.0</version>
        </dependency>