Memory leak in latest version

38 views
Skip to first unread message

Alexander Zuban

unread,
Apr 4, 2008, 7:27:01 AM4/4/08
to H2 Database
Hello H2 Team,

Thank you for your work on H2 database.
Seems we faced with a state when latest DB release lead to memory
leak. I check heap with jmap here is top from the instances count:

295211 instances of class org.h2.util.ObjectArray
292649 instances of class [Lorg.h2.expression.Expression;
292636 instances of class org.h2.result.LocalResult
35349 instances of class org.h2.result.SimpleRowValue
20703 instances of class org.h2.value.ValueTimestamp
17334 instances of class org.h2.value.ValueLong
16146 instances of class [Lorg.h2.value.Value;
15898 instances of class org.h2.value.ValueInt
13244 instances of class org.h2.result.Row
12245 instances of class org.h2.value.ValueString
2665 instances of class org.h2.result.SimpleRow
2410 instances of class org.h2.value.ValueBytes
1578 instances of class org.h2.index.BtreeLeaf

I found that memory leak caused by certain query:

update file set deleted=? where fs_id=? and (exists (select
path1_.path_id from path path1_ where file.path_id=path_id and
(path1_.path like ?)))

This query take 1-2MB of the memory. My DB is comparable small - about
4000 objects in single table.

(We are using hibernate in our app). When I switch 3 version back, app
run without leaks.

Hope you will be able to fix in in further releases.

Thank you in advance,
Alexander Zuban

Thomas Mueller

unread,
Apr 6, 2008, 4:19:36 AM4/6/08
to h2-da...@googlegroups.com
Hi,

Thanks for your help! I have found the reason for the problem: the
session keeps a set of temporary result sets so that temporary files
are deleted early. However this is not essential. It is possible to
disable this feature, but you need to recompile H2. The problem is
Session.addTemporaryResult(..). If you remark all code in this method
the leak is gone.

This problem will be fixed for the next release (the fix is a bit more
complicated).

Regards,
Thomas

Reply all
Reply to author
Forward
0 new messages