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.  [ 6 posts ] 
Author Message
 Post subject: Memory leak of application using hibernate
PostPosted: Tue Sep 01, 2009 6:14 pm 
Newbie

Joined: Wed Jul 29, 2009 12:02 pm
Posts: 11
Hello everybody,

I am developing an application using Jboss and Hibernate 3.1, and I have lots of problems because my system JVM heap gets full after some minutes of loadtests.

I have profiled the memory of jboss and I have realized that class org.hibernate.hql.QueryTranslator is instantiating, and instances of the class are never deallocaed from memory.

Do you have any idea, what could be the problem ?


Top
 Profile  
 
 Post subject: Re: Memory leak of application using hibernate
PostPosted: Tue Sep 01, 2009 8:46 pm 
Expert
Expert

Joined: Tue May 13, 2008 3:42 pm
Posts: 919
Location: Toronto & Ajax Ontario www.hibernatemadeeasy.com
Are you closing the session after each test?

_________________
Cameron McKenzie - Author of "Hibernate Made Easy" and "What is WebSphere?"
http://www.TheBookOnHibernate.com Check out my 'easy to follow' Hibernate & JPA Tutorials


Top
 Profile  
 
 Post subject: Re: Memory leak of application using hibernate
PostPosted: Wed Sep 02, 2009 6:59 am 
Newbie

Joined: Wed Jul 29, 2009 12:02 pm
Posts: 11
Yes, this is the Code :

public List<Iatrigger2channel> listIatrigger2channelByPlatformNotExpired(String itvplat_fk, String channelfid) throws HibernateException {

Session session = null;
try {

session = sessionFactory.openSession();
String sQuery = "FROM Iatrigger2channel WHERE 1=1 AND ITVPLAT_FK ="+itvplat_fk+" AND CHANNELFUNCTIONALID='"+channelfid+"'";
java.sql.Timestamp timestamp = getCurrentJavaSqlTimestamp();
sQuery+=" AND VALIDFROM <= '" + timestamp + "' AND '" + timestamp + "' <= VALIDTO";
log.debug("listIatrigger2channelByPlatformNotExpired.sQuery: " + sQuery);
Query query = session.createQuery(sQuery);

if ( query != null )
{
query.setMaxResults(10);

}

List<Iatrigger2channel> result = query.list();


session.close();
return result;

} catch (HibernateException e) {
throw e;
}
}


Top
 Profile  
 
 Post subject: Re: Memory leak of application using hibernate
PostPosted: Wed Sep 02, 2009 7:04 am 
Beginner
Beginner

Joined: Fri Jun 26, 2009 6:59 am
Posts: 23
poor use of exceptions.
add the session.close(); to a finally{} block


Top
 Profile  
 
 Post subject: Re: Memory leak of application using hibernate
PostPosted: Wed Sep 02, 2009 10:21 am 
Newbie

Joined: Wed Jul 29, 2009 12:02 pm
Posts: 11
I change the code to this, but still the QueryTranslator stucks in memory !!!

public List<Iatrigger2channel> listIatrigger2channelByPlatformNotExpired(String itvplat_fk, String channelfid) throws HibernateException {

Session session = null;
try {

session = sessionFactory.openSession();
log.debug("Opening Session for Hibernate");
String sQuery = "FROM Iatrigger2channel WHERE 1=1 AND ITVPLAT_FK ="+itvplat_fk+" AND CHANNELFUNCTIONALID='"+channelfid+"'";
java.sql.Timestamp timestamp = getCurrentJavaSqlTimestamp();
sQuery+=" AND VALIDFROM <= '" + timestamp + "' AND '" + timestamp + "' <= VALIDTO";
log.debug("listIatrigger2channelByPlatformNotExpired.sQuery: " + sQuery);
Query query = session.createQuery(sQuery);

if ( query != null )
{
query.setMaxResults(10);

}

List<Iatrigger2channel> result = query.list();


//session.close();
//log.debug("Closing Session for Hibernate");
return result;

} catch (HibernateException e) {
throw e;
} finally {
if (session != null){
try {
session.close();
log.debug("Closing Session for Hibernate");
} catch ( HibernateException ignore) {
// Ignore
}
}
}
}


Top
 Profile  
 
 Post subject: Re: Memory leak of application using hibernate
PostPosted: Thu Sep 03, 2009 10:50 am 
Newbie

Joined: Wed Jul 29, 2009 12:02 pm
Posts: 11
The problem is related with the compilation of HQL, I will open a new thread about this problem


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 6 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.