Unloading classes in java?

前端 未结 7 1762
遥遥无期
遥遥无期 2020-11-22 01:40

I have a custom class loader so that a desktop application can dynamically start loading classes from an AppServer I need to talk to. We did this since the amount of jars th

7条回答
  •  面向向阳花
    2020-11-22 02:11

    Classes have an implicit strong reference to their ClassLoader instance, and vice versa. They are garbage collected as with Java objects. Without hitting the tools interface or similar, you can't remove individual classes.

    As ever you can get memory leaks. Any strong reference to one of your classes or class loader will leak the whole thing. This occurs with the Sun implementations of ThreadLocal, java.sql.DriverManager and java.beans, for instance.

提交回复
热议问题