-->
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: ThreadLocal Pattern question
PostPosted: Mon May 17, 2004 12:17 pm 
Newbie

Joined: Wed Dec 10, 2003 1:29 pm
Posts: 8
Location: Chicago, USA
I think I must be missing something basic - my apologies in advance. I have started using Hibernate with the ThreadLocal session pattern for a read-only Struts based application. A user submits a query, gets a session, gets results, and then returns to do another search. The problem is that everytime the same user searches, a new session is created and the objects that were generated for the previous search remain in memory - I can see them growing in a profiler on each user submission. The session appears to be gone in that the class with the Threadlocal pattern can't find it, but its still there with its objects in memory. If I could get it back I could disconnect or evict objects or something like that, but I don't know when to do that until a user actually resubmits a query, and by then the session appears to be gone. Any hints on what I am doing wrong? I would include the code but it is exactlhy whats in the hibernate doc for the quickstart with Tomcat. When I just get a Session in a singleton manner, the memory problem goes away - might this be safe for this type of application - read only?

sg


Top
 Profile  
 
 Post subject:
PostPosted: Mon May 17, 2004 12:42 pm 
CGLIB Developer
CGLIB Developer

Joined: Thu Aug 28, 2003 1:44 pm
Posts: 1217
Location: Vilnius, Lithuania
Why do you think it is a problem, doe's it throw OutOfMemoryError or garbage collection pauses are too long for this application ?


Top
 Profile  
 
 Post subject:
PostPosted: Mon May 17, 2004 12:48 pm 
Newbie

Joined: Wed Dec 10, 2003 1:29 pm
Posts: 8
Location: Chicago, USA
Out of memory occurs eventually yes.


Top
 Profile  
 
 Post subject:
PostPosted: Mon May 17, 2004 12:56 pm 
CGLIB Developer
CGLIB Developer

Joined: Thu Aug 28, 2003 1:44 pm
Posts: 1217
Location: Vilnius, Lithuania
"session.close" must clear local cache, try to debug in IDE, it must be very trivial to find, I do not think some hibernate version can be broken this way, many people use this design.


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.