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...