-->
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.  [ 20 posts ]  Go to page 1, 2  Next
Author Message
 Post subject: EHCache thread leak?
PostPosted: Mon Mar 01, 2004 2:26 pm 
Beginner
Beginner

Joined: Wed Nov 19, 2003 10:29 pm
Posts: 27
I've found that when using the 2nd level cache with EHCache, it seems to leak one thread for every cached entity and two for the query cache. This is after calling sessionfactory.close(), which is supposed to release all resources relating to the sessionfactory.

Oddly, it is only the threads marked 'Expiry' that leak. Each 'Expiry' thread has a counterpart 'Spool' thread, otherwise named the same. The 'Spool' threads get properly terminated. It's only the 'Expiry' ones that don't get cleaned up. This is, of course, creating a leak every time my servlet context gets reloaded.

In case it makes a difference, EHCache is configured to cache my entities 'eternally'.

Is this a bug in EHCache?

I'm using Hibernate 2.1.1 and whatever version of EHCache comes with.


Top
 Profile  
 
 Post subject: What ever happened with this?
PostPosted: Tue Oct 11, 2005 6:44 pm 
Regular
Regular

Joined: Thu Sep 09, 2004 6:46 pm
Posts: 96
What ever happened with this? Did it turn out to be an issue?If so what did you do about it?


Top
 Profile  
 
 Post subject: Nope...
PostPosted: Tue Oct 11, 2005 7:56 pm 
Beginner
Beginner

Joined: Wed Nov 19, 2003 10:29 pm
Posts: 27
Still don't know enough about it and haven't looked in to it since. Usually, I restart my container every couple of re-loads anyway, but ya, this shouldn't be happening.


Top
 Profile  
 
 Post subject: did you open a JIRA?
PostPosted: Tue Oct 11, 2005 7:58 pm 
Regular
Regular

Joined: Thu Sep 09, 2004 6:46 pm
Posts: 96
did you open a JIRA?


Top
 Profile  
 
 Post subject: I will...
PostPosted: Tue Oct 11, 2005 8:00 pm 
Beginner
Beginner

Joined: Wed Nov 19, 2003 10:29 pm
Posts: 27
I will if I can get somebody else to confirm that this is happening with them. Also, is it still happening in Hibernate 3/3.1? I haven't tested that particular problem with it.


Top
 Profile  
 
 Post subject: I seem to be having same problem with 3.1 beta3.
PostPosted: Tue Oct 11, 2005 8:24 pm 
Regular
Regular

Joined: Thu Sep 09, 2004 6:46 pm
Posts: 96
I seem to be having same problem with 3.1 beta3.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Oct 11, 2005 10:19 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 3:00 pm
Posts: 1816
Location: Austin, TX
Debug into org.hibernate.cache.EhCacheProvider.stop() and make sure CacheManager.shutdown() is being executed.


Top
 Profile  
 
 Post subject: Under what conditions should that method run?
PostPosted: Fri Oct 14, 2005 2:27 pm 
Regular
Regular

Joined: Thu Sep 09, 2004 6:46 pm
Posts: 96
Under what conditions should that method run?


Top
 Profile  
 
 Post subject:
PostPosted: Fri Oct 14, 2005 3:56 pm 
Expert
Expert

Joined: Mon Jul 04, 2005 5:19 pm
Posts: 720
guys, are you calling SessionFactory.close ?


Top
 Profile  
 
 Post subject: When would I be calling that?
PostPosted: Fri Oct 14, 2005 4:15 pm 
Regular
Regular

Joined: Thu Sep 09, 2004 6:46 pm
Posts: 96
When would I be calling that? I'm running a web app and sessionFactory is a singleton. Basically the use is in the normal spring documented way of using hibernate.


Top
 Profile  
 
 Post subject:
PostPosted: Fri Oct 14, 2005 4:23 pm 
Expert
Expert

Joined: Mon Jul 04, 2005 5:19 pm
Posts: 720
Code:
public class GarpincListener implements ServletContextListener {
     
   public void contextInitialized(ServletContextEvent event) {
   }
   
   public void contextDestroyed(ServletContextEvent event) {
      Hibernate3Util.getSessionFactory().close();
   }
   
}


Top
 Profile  
 
 Post subject: Can you elaborate a bit please?
PostPosted: Fri Oct 14, 2005 4:33 pm 
Regular
Regular

Joined: Thu Sep 09, 2004 6:46 pm
Posts: 96
Can you elaborate a bit please? How does that fit into the spring/hibernate scenario?


Top
 Profile  
 
 Post subject:
PostPosted: Fri Oct 14, 2005 5:27 pm 
Expert
Expert

Joined: Mon Jul 04, 2005 5:19 pm
Posts: 720
your application, spring or not, should be calling close() whenever it restarts. close() cleans up resources - and if it is not being called then you have something entirely different than the original poster.


Top
 Profile  
 
 Post subject: It's a webapp so I almost don't care what happens w restart
PostPosted: Sun Oct 16, 2005 2:40 pm 
Regular
Regular

Joined: Thu Sep 09, 2004 6:46 pm
Posts: 96
It's a webapp so I almost don't care what happens w restart. Most times we restart we restart the jvm anyway. The only time I would worry about such things is with redeploy which we don't do. Anyway what I am worried about is for a continuously running app. We are seeing a lot more ehcache threads than we should be and this is indicating a thread leak.


Top
 Profile  
 
 Post subject: In any case, spring does close session factory on app close.
PostPosted: Sun Oct 16, 2005 2:44 pm 
Regular
Regular

Joined: Thu Sep 09, 2004 6:46 pm
Posts: 96
public class LocalSessionFactoryBean implements FactoryBean, InitializingBean, DisposableBean {


/**
* Close the SessionFactory on bean factory shutdown.
*/
public void destroy() throws HibernateException {
logger.info("Closing Hibernate SessionFactory");
this.sessionFactory.close();
}


all disposable beans are cleaned up at app close including this one.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 20 posts ]  Go to page 1, 2  Next

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.