-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 4 posts ] 
Author Message
 Post subject: Open session in view + JSTL forEach = memory leak?
PostPosted: Fri Jul 02, 2004 12:40 pm 
Newbie

Joined: Wed Jan 07, 2004 5:30 pm
Posts: 11
Location: SF, CA
Hi folks. I have a Struts-based hibernate app which I've been working on for quite a while. Recently, as my objects grow larger and more complex, it's come to my attention that I've got a memory leak (our staging server was going down after a day of heavy use with OutOfMemory errors).

Using JProfiler, I had a look at the heap and realized that some of my more complex objects (having several child collections of complex objects) were 1 meg + (deep) each. This was generally fine in my view as they were pretty much always bound to the request, and the lazy collections were fleshed out using a servlet filter similar to the one shown here: http://www.hibernate.org/43.html

The problem is, *something* was not allowing those objects to be garbage collected. Oddly enough, all evidence so far points to the JSTL forEach tag. The tag seems to be steadfastly holding a reference to collection it iterated through even though the session has been closed and the request is completed. This is pretty worrying stuff.

I've replaced the offending "forEach" instance looping through my large objects with scriptlet code, and lo and behold, these objects GC just fine. Then I can change it back to using the JSTL tag and the objects stick. It's very reproducable, which is why i'm bothering to say anything about it here.

Now, as I'm generally pro-JSTL, I'm kind of irritated that this is happening. Has anyone else experienced this? Does anyone have any suggestions? Velocity? My own custom tag?

I just thought I'd put this out there in case anyone ran into the same thing...


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jul 02, 2004 1:04 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 3:00 pm
Posts: 1816
Location: Austin, TX
Nope seen that, and I've used JSTL in two extremely large applications.


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jul 02, 2004 1:23 pm 
Newbie

Joined: Wed Jan 07, 2004 5:30 pm
Posts: 11
Location: SF, CA
Steve, in those applications, which compiler was used to compile the JSPs? I'm stuck to using javac and thinking jikes might help. This could be a jasper issue...

BTW, i've since found that using the Struts logic:iterate tag helps when you specify the object you're iterating through:

Code:
<logic:iterate id="article" name="articles" scope="request" type="Article">


I'm no expert on tag construction, but I think the JVM is more likely to put a higher priority on GCing an object that it knows is potentially huge (Article) than any joe schmo bean that it knows nothing about.

Anyways, thanks for the feedback. I'm glad to have a solution...


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jul 02, 2004 4:34 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 3:00 pm
Posts: 1816
Location: Austin, TX
The JVM is not going to give consideration to "weight" of an object it is considering for GC. I've not used the iterate tag and so have not looked at the source for it. I'd be curious for its actual usage of that value (I would assume it is just doing some element validation as it is iterating).

I don't remember the jsp compiler used. It the default one used in WebLogic, whatever that is. Have you specified to have it keep the generated source file it compiles? It might be worth-while to take a look at those generated sources to see what is going on after it gets compiled.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 4 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.