ClassLoaders are stored in Permanent generation memory . And as specified in white paper of java Memory Management in the Java HotSpot™ Virtual Machine, permanent generation memory is garbage collected for sure. So, Does custom Classloader still lead to memory leakage? If yes, then how come that it happens?
UPDATE
With the help of @Marko Topolnik and @Prunge I got my doubt clear. And following points are made out about ClassLoaders and Memory Leaks:
- Custom
ClassLoaders are not stored in Perm generation. - Custom
ClassLoadercould lead to memory leakage ifClassLoderis out of scope but the classes that it has loaded is still referred by the Application no matter if we set theClassLoaderobject tonull. - If we don't need a given
ClassLoaderobject then we should make sure that all the references to the objects developed from loaded classes should benull. - If any of the classes loaded by
ClassLoaderis not eligible forGCthen the ClassLoader will not beGCed.