I've attached two patches to https://issues.apache.org/jira/browse/ OPENJPA-285. I've tested deploy/undeploy scenarios with the two patches. They appear to clear up ClassLoader memory leaks associated with deployment/undeployment of applications.

The patch to ImplHelper is straight-forward, IMO. _assignableTypes maintains a Map of Class, Map pairs. The Class key is WEAK. The assignableTo Maps need to use WEAK keys, also. Otherwise, there is a chain of HARD references which will prevent GC of the 'to' Class' ClassLoader.

The PCRegistry change was the subject of earlier discussion. I see no mechanism of WeakReferences/Stringified object names that would permit the appropriate Garbage Collection of the Meta.pc object (and it's associated ClassLoader). Instead, this patch adds a PCRegistry.deregister(ClassLoader) method. When a ClassLoader is no longer viable, Embedders may use this method to cause PCRegistry to remove Meta objects from the _metas Map.

My testing shows that these two patches clear up the ClassLoader memory leaks (at least in the scenarios I've tested). Hoping that we can get these patches applied...

Thanks!

--kevan

Reply via email to