|
From: Matt R. <li...@ra...> - 2004-05-25 07:03:11
|
I tried CVS Head in 2 Spring apps and all tests pass. Matt > -----Original Message----- > From: spr...@li...=20 > [mailto:spr...@li...] > On Behalf Of Colin Sampaleanu > Sent: Monday, May 24, 2004 7:49 PM > To: spr...@li... > Subject: Re: [Springframework-developer] Cleanup of context=20 > resources on webapp reload >=20 >=20 > Just gave CVS Head a go with my main app (was using source=20 > about a week=20 > old, previously). All seems ok for basic container operations,=20 > transactions, and Hibernate. Unit tests all run fine on the couple of=20 > machines I build on... >=20 >=20 > j=FCrgen h=F6ller [werk3AT] wrote: >=20 > >I've just spent about 10 hours profiling Spring, using the Image=20 > >Database and Petclinic samples. (BTW, I've used an=20 > evaluation version of JProfiler from ej-technologies - nice product!) > >=20 > >Although I still don't completely understand the garbage collection=20 > >behavior, I've figured out the following issues. Each of=20 > them simply prevents the respective classes from getting=20 > garbage collected on destruction of the class loader (e.g. on=20 > Tomcat web app shutdown). > >=20 > >- A classic singleton with a class variable holding the object. I've=20 > >reworked GlobalAdvisorAdapterRegistry and=20 > SQLErrorCodesFactory to hold the respective singleton as a=20 > WeakReference. > >=20 > >- A static cache. I've reworked CachedIntrospectionResults to use a=20 > >WeakHashMap with WeakReferences as values. > >=20 > >- A ThreadLocal with a default other than null. I've reworked=20 > >TransactionSynchronizationManager to use null as default for=20 > the resource map, setting a HashMap there on demand, removing=20 > the entire HashMap when unbinding the last resource. > >=20 > >- Constants that define a full object. We have a number of=20 > those, for=20 > >example ClassFilters.TRUE and=20 > AdvisedSupport.EMPTY_TARGET_SOURCE. I've tried for quite a=20 > while, but I haven't been able to figure out a way to define=20 > such constants such that they will be garbage collected. > >=20 > >The latter programming style is not uncommon, so I really don't=20 > >understand why it causes trouble with garbage collection.=20 > Hibernate uses a similar style for its FlushMode, for example. > >=20 > >In general, other frameworks like CGLIB, Hibernate, Velocity=20 > have huge=20 > >resource leaks on web app shutdown, while just the constants=20 > issue remains with Spring now. As long as those huge=20 > third-party leaks are not addressed, I'm not worried at all=20 > by the single remaining Spring issue. > >=20 > >As I initially said, we shouldn't exaggerate the problem, as it=20 > >basically just affects hot reloading of web apps - mainly a=20 > development feature anyway. We need to make that clear to=20 > users too, to avoid comments a la "Spring is not usable for=20 > real apps because it leaks on hot redeployment". > >=20 > >Please, everybody, give the current CVS head a sanity check=20 > tomorrow.=20 > >There shouldn't be any issues: the test suite passes, the=20 > sample apps run properly. Still, I'd feel more comfortable if=20 > we make sure that no subtle side effects have been introduced. > >=20 > >For this reason, I will delay release 1.0.2 till tomorrow night. > >=20 > >Juergen > >=20 > > > >________________________________ > > > >Von: spr...@li...=20 > im Auftrag=20 > >von j=FCrgen h=F6ller [werk3AT] > >Gesendet: Sa 22.05.2004 15:52 > >An: spr...@li... > >Betreff: Re: [Springframework-developer] Cleanup of context=20 > resources on webapp reload > > > > > > > >So basically, all static caches cause resource leaks when=20 > restarting a=20 > >Tomcat web app? I wonder why this happens... The class loader should=20 > >completely dissolve all classes that it has loaded in its lifetime,=20 > >including static caches. Or have I misunderstood something=20 > here? Anyone=20 > >having in-detail experience with handling such a scenario? > > > >Juergen > > > > > >________________________________ > > > >Von: spr...@li...=20 > im Auftrag=20 > >von Dmitriy Kopylenko > >Gesendet: Di 04.05.2004 18:02 > >An: spr...@li... > >Betreff: Re: [Springframework-developer] Cleanup of context=20 > resources on webapp reload > > > > > > > >Well, > > > >for instance SQLErrorCodesFactory is a singleton(GoF, not=20 > Spring) which=20 > >caches SQLErrorCodes internally in the Map with strong references.=20 > >Again, I don't know if trying to use WeakHashMap there would do the=20 > >trick... > > > >Dmitriy > > > >Tim Kettering wrote: > > > > =20 > > > >>I looked at it some more this morning, and basically what I did was=20 > >>start up tomcat w/ the webapp in the profiler, then after=20 > it was done=20 > >>starting up I used tomcat's manager to stop the context. =20 > This should > >>destroy all resources related to the context. Here is a list of > >>spring related stuff that still were in memory after the=20 > context was=20 > >>closed. Other stuff was cleaned up just fine. > >> > >>org.springframework.beans.CachedIntrospectionResults > >>org.springframework.jdbc.support.SQLCodes > >>org.springframework.core.Constants > >>org.springframework.aop.framework.AdvisedSupport$1 > >>org.springframework.aop.framework.adapter.BeforeAdviceAdapter > >>org.springframework.aop.framework.adapter.AfterReturningAdvi > ceAdapter > >>org.springframework.jdbc.support.SQLErrorCodesFactory > >>org.springframework.transaction.support.TransactionSynchroni > zationMana > >>ge > >>r$1 > >>org.springframework.transaction.interceptor.RollbackRuleAttribute > >>org.springframework.aop.framework.adapter.ThrosAdviceAdapter > >>org.springframework.aop.Pointcut$1 > >>org.springframework.aop.framework.adapter.GlobalAdvisorAdapt > erRegistry > >> > >>On May 3, 2004, at 3:28 PM, Dmitriy Kopylenko wrote: > >> > >> =20 > >> > >>>I'm just wondering, would the use of WeakHashMap in=20 > >>>CachedIntrospectionResults help? > >>> > >>>Dmitriy. > >>> > >>>Tim Kettering wrote: > >>> > >>> =20 > >>> > >>>>I posted this to the users list last week and did not receive any=20 > >>>>reply on it, so I'm posting it again here on the=20 > developer list, in > >>>>hopes i could get an reply from someone here. I'm trying to > >>>>determine if its something I should be doing myself, or if hte=20 > >>>>spring context should be cleaning up those resources by=20 > itself on=20 > >>>>the .close() call. Further profiling shows that there are=20 > >>>>duplicate instances of SQLError and hibernate proxy classes=20 > >>>>hanging around afterwards too. Other objects do get cleaned up=20 > >>>>properly. > >>>>-------- > >>>>Hi everyone, > >>>>We're (meaning me) looking into some resource leaks that are > >>>>occuring when our webapp context gets reloaded. I found that > >>>>context.close() needs to be called on the destroy() method of > >>>>plugin we're using, and it works for a good majority of=20 > the objects > >>>>we were seeing leaked, but there are some objects that=20 > I'm unable > >>>>to make go away. Object in question is the: > >>>>org.springframework.beans.CachedIntrospectionResults > >>>>Whenever I reload the context - the profiler I'm using=20 > shows that I=20 > >>>>have essentially a duplicate group of those objects (same=20 > instance=20 > >>>>count) as the original, and successive reloads will continue to=20 > >>>>duplicate this. > >>>>The profiler also shows the final reference to those=20 > objects like this: > >>>>100% - 1008 bytes - 63 alloc.=20 > >>>>org.springframework.context.support.ClassPathXmlApplicatio > nContext.<in > >>>>it > > >>>>So basically I guess what I'm asking is for ideas or=20 > suggestions on > >>>>how I could get those to clean up. This bean doesnt=20 > show up in the > >>>>Spring javadocs. And looking in CVS says its a package=20 > level bean, > >>>>not for application use, so I'm thinking that closing the context > >>>>should (in theory) clean this up? Thanks in advance. > >>>>-tim > >>>>------------------------------------------------------- > >>>>This SF.Net email is sponsored by: Oracle 10g > >>>>Get certified on the hottest thing ever to hit the=20 > market... Oracle > >>>>10g. Take an Oracle 10g class now, and we'll give you the=20 > exam FREE. > >>>>http://ads.osdn.com/?ad_id=3D3149&alloc_id=3D8166&op=3Dclick > >>>> =20 > >>>> >=20 >=20 >=20 >=20 > ------------------------------------------------------- > This SF.Net email is sponsored by: Oracle 10g > Get certified on the hottest thing ever to hit the market...=20 > Oracle 10g.=20 > Take an Oracle 10g class now, and we'll give you the exam=20 > FREE. http://ads.osdn.com/?ad_id=3D3149&alloc_id=3D8166&op=3Dclick > _______________________________________________ > Springframework-developer mailing list=20 > Spr...@li... > https://lists.sourceforge.net/lists/listinfo/springframework-developer >=20 |