I'm in a place where repeated deploy-undeploy actions of the same war-file on server (tomcat) is leading to PermGen OutOfMemoryError. My goal is to make sure that I unload all classes when the war is undeployed.
Here is a class I have:
public class ClassA {
//static variables & methods
//instance variables & methods
private EnumInsideClassA myState = EnumInsideClassA.VALUE1;
private enum EnumInsideClassA
{
VALUE1,
VALUE2
}
}
When I cleared all the references of ClassA, I could not see ClassA and it was unloaded when war was un-deployed. However, I still see the enum references and ClassA$EnumInsideClassA is not unloaded.
There is no getter for 'myState' instance variable and it just going to be used with ClassA
Any help is appreciated
However, I still see the enum references and ClassA$EnumInsideClassA is not unloaded.
If you can see the enum
references, you should be able to see where they are. Now there will be some enum references accessible via a hidden static field of the enum class, but these should be circular references and shouldn't cause the enum
to remain reachable. See if there are enum
references somewhere else.