> > Thanks. I've filed this as http://bugs.caucho.com/view.php?id=4628 > Thank you for fixing the bug so quickly. Is it possible to backport it to 3.1 as well? (if not: is a workaround available?)
Thanks. Patric > >> Please have a look at >> resin-3.1.10\modules\jpa\src\javax\persistence\Persistence.java >> >> On line 51 there's a WeakHashMap defined, which maps the classloader >> to the corresponding PersistenceProvider instances: >> >> private static WeakHashMap<ClassLoader,PersistenceProvider[]> >> _providerMap = new WeakHashMap<ClassLoader,PersistenceProvider[]>(); >> >> >> The problem is that a PersistenceProvider instance may reference the >> key indirectly >> (which is at least true when not using Amber, e.g. EclipseLink) >> The loaded class will of course reference its classloader, which is >> the web application's classloader. >> However according to the javadocs this will prevent the removal of the entry: >> >> "Thus care should be taken to ensure that value objects do not >> strongly refer to their own keys, >> either directly or indirectly, since that will prevent the keys from >> being discarded." >> >> With the consequence that the EnvironmentClassLoader cannot be garbage >> collected. >> >> When looking at the GC roots (for a classloader from a stopped application) >> this can be seen easily: >> >> Class Name >> | Shallow Heap | Retained Heap >> ------------------------------------------------------------------------------------------------------------------ >> com.caucho.loader.EnvironmentClassLoader @ 0xe68362d0 >> | 376 | 131.077.664 >> '-<classloader> class org.eclipse.persistence.jpa.PersistenceProvider >> @ 0xd3bda6d8| 0 | 0 >> '-<class> org.eclipse.persistence.jpa.PersistenceProvider @ >> 0xe7bb2010 | 24 | 40 >> '- [3] javax.persistence.spi.PersistenceProvider[4] @ >> 0xe7bb2020 | 56 | 144 >> '- value java.util.WeakHashMap$Entry @ 0xe7c72ca8 >> | 72 | 432 >> '- [11] java.util.WeakHashMap$Entry[16] @ 0xe118fc18 >> | 152 | 800 >> '- table java.util.WeakHashMap @ 0xe118fbe8 >> | 72 | 928 >> '- _providerMap class javax.persistence.Persistence >> @ 0xd1fc55a8 | 32 | 960 >> '- [1152] java.lang.Object[1280] @ 0xe0b40378 >> | 10.264 | 1.774.424 >> ------------------------------------------------------------------------------------------------------------------ >> >> As you can see, the second last line (_providerMap class >> javax.persistence.Persistence @ 0xd1fc55a8) which is actually >> a caucho class, references the old EnvironmentClassLoader. >> So in my case, 131 MB will not get released. >> >> If I am right - is there a workaround available? >> (Is it possible to configure the EnvironmentClassLoader that it will not load >> the PersistenceProvider/Persistence class from Amber but from the JPA >> implementation which my application provides?) >> >> Thank you and best regards, >> Patric >> >> >> >> >> _______________________________________________ >> resin-interest mailing list >> [email protected] >> http://maillist.caucho.com/mailman/listinfo/resin-interest >> > > > > _______________________________________________ > resin-interest mailing list > [email protected] > http://maillist.caucho.com/mailman/listinfo/resin-interest _______________________________________________ resin-interest mailing list [email protected] http://maillist.caucho.com/mailman/listinfo/resin-interest
