-->
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.  [ 2 posts ] 
Author Message
 Post subject: Difference between criteria API / HQL memory usage
PostPosted: Wed Jan 12, 2005 6:23 pm 
Newbie

Joined: Wed Jan 12, 2005 6:02 pm
Posts: 2
I have a Quartz scheduled Job that is run every minute.
The Job uses hibernate.
For some reason it seems that when using HQL queries, some objects never get cleaned by the garbage collector (checked with profiler).

The method called every minute using HQL:

public List getItems() {
Session session = null;
try {
session = sessionFactory.openSession();
List items = session.find("FROM item IN CLASS Item WHERE item.process=1 ORDER BY item.id");
return items;
} catch (HibernateException e) {
throw new RuntimeException(e.getMessage(), e);
} finally {
try {
if (session!=null) session.close();
} catch (HibernateException e) {
throw new RuntimeException(e.getMessage(), e);
}
}
}

The method converted to use the Criteria API

public List getItems() {
Session session = null;
try {
session = sessionFactory.openSession();
Criteria c = session.createCriteria(Item.class);
c = c.add(Expression.eq("process", new Integer(1)));
c = c.addOrder(Order.asc("id"));
List l = c.list();
return l;

} catch (HibernateException e) {
throw new RuntimeException(e.getMessage(), e);
} finally {
try {
if (session!=null) session.close();
} catch (HibernateException e) {
throw new RuntimeException(e.getMessage(), e);
}
}
}

Using the Criteria API no objects are left hanging behind, but using the HQL version, the following classes are never garbage collected

a) net.sf.hibernate.type.ManyToOneType
b) net.sf.hibernate.hql.QueryTranslator
c) net.sf.hibernate.sql.QueryJoinFragment

For each run (ie. every minute), there are created 2 objects of type a) and one of type b) and c) each.

Any ideas what's happening?
Using hibernate 2.1.4 with mysql.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jan 13, 2005 3:42 am 
Newbie

Joined: Wed Jan 12, 2005 6:02 pm
Posts: 2
Ok, forget about it.
Apparently the objects get cleaned out eventually, it just takes a while.


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