What is a Leaking Class Loader?
A leaking class loader is just like any other leak: an object which is still around even though it is not used by the application anymore. Because a class loader keeps references to all classes it defined, this is particularly wasteful in terms of perm space. If you then have a system with regular deploy-undeploy-deploy cycles like an application server, these leaks will quickly eat up the available perm space. And increasing the perm space is no option here… The above mentioned article uses the following example: The servlet LeakServlet is logging something using the Java logging facilities and then writes a Hello World! into the output stream. Please note the anonymous inner class assigned to theCUSTOMLEVEL attribute (Level’s constructor is protected). I deployed this servlet inside a WAR and then re-deployed it again. Then I took a heap dump (see my previous blog or Memory Analyzer’s WIKI). Running the Class Loader Overview, I get this result: As you can see, there are two instances