-->
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.  [ 1 post ] 
Author Message
 Post subject: Leaking memory using Hibernate + mysql in Tomcat - Help
PostPosted: Mon Dec 21, 2009 12:45 pm 
Newbie

Joined: Wed Feb 18, 2009 12:56 pm
Posts: 5
Hello,

We are leaking memory in our webapps, and using some of the heap analyzers we are able to narrow it down to potentially leaking connections.

Some of the top leaks as shown by jmap are in the bottom.

The webapp uses hibernate 3 with mysql 5.0.4 driver. It also uses a framework to help beans do the query. Most of it is boiler plate that following this pattern.

public static <T, U> List<U> queryBy(Class clazz ) throws Exception {
Session session = getSession();
Criteria criteria = session.createCriteria(clazz);
//
// Add to the Criteria -
List<U> theList = criteria.list();

session.close();

return theList;
}

The callers then iterate through the list returned by this method and call list.clear(). Can the above code leak connections? (ps: I have simplified the exception handling for illustration). One of the thoughts is to upgrade to jdbc driver, but i am not convinced it is the driver.

Any help is greatly appreciated.

---------------> Objects on the the heap ---------------<

Objects of the heap. (Size / Count/ Object)
32468792 508833 char[]
31746288 235370 * ConstMethodKlass
18459632 249651 byte[]
16949688 235370 * MethodKlass
11681720 17095 * ConstantPoolKlass
11602800 483450 java.lang.String
10235008 319844 nu.xom.Attribute
7927056 232842 java.lang.Object[]
7575808 17094 * InstanceKlassKlass
6926368 13792 * ConstantPoolCacheKlass
6743960 168599 nu.xom.Element
5346216 222759 java.util.ArrayList
3317496 138229 java.util.HashMap$Entry
3301840 206365 nu.xom.Text
3292816 67844 int[]
2884816 70947 * SymbolKlass
2686088 24700 java.util.HashMap$Entry[]
2190320 27379 java.lang.reflect.Method
1762176 18356 java.lang.Class
1582112 21965 short[]
1436816 28322 java.lang.Object[]
1323240 62278 java.lang.String[]
1045512 3319 * MethodDataKlass
905520 22638 java.util.HashMap
583400 14585 org.apache.catalina.loader.ResourceEntry
529560 7355 java.lang.reflect.Field
439312 27457 java.lang.StringBuffer
424920 17705 java.util.Hashtable$Entry
374832 1233 * ObjArrayKlassKlass
372848 21890 java.lang.Class[]
308184 12841 com.sun.org.apache.xerces.internal.xni.QName
292704 6098 java.nio.HeapCharBuffer
287664 5993 java.nio.HeapByteBuffer
253488 4331 java.lang.String[][]
244720 2430 java.util.Hashtable$Entry[]
233568 14598 java.lang.Integer
218256 10735 boolean[]
188160 2940 com.mysql.jdbc.ConnectionProperties$BooleanConnectionProperty
35840 560 com.mysql.jdbc.ConnectionProperties$IntegerConnectionProperty
29120 455 com.mysql.jdbc.ConnectionProperties$StringConnectionProperty
28840 35 com.mysql.jdbc.Connection


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

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.