views:

34

answers:

1

Pardon the newbie question.

My data model is really simple (two tables; 200 rows in one, 10,000 in the other; natural join between both).

I'm using Hibernate to attempt a simple read/update on these tables. Doing so keeps throwing OutOfMemory errors (1GB assigned to my JVM).

This seems very unlikely due to natural memory needs, and more likely that I am omitting some basic step in Hibernate.

I'm at the point where I've even replaced most of my actual Hibernate object accesses with direct SQL (absurd, I know). But even getCurrentSession().createSQLQuery(...) is resulting in OOM errors.

Can anyone point me in the right direction?

+1  A: 

most common cause of OutOfMemory errors when using Hibernate?

A common cause of OOM is a lack of control of the size of the session-level cache (by calling flush and clear on the session at regular intervals, ideally, the same interval as the JDBC batch size) when dealing with large collections of entities. See the Chapter 13. Batch processing for more on this.

But your case is not that impressive. What are you doing exactly? And how (even pseudo code might help)?

Pascal Thivent
I'm not calling clear() at all, LOL. I'll check this out, thanks.
Aaron F.
@Aaron Note than most of time, you don't need to "micro manage" the session like this. This is only useful when you start to deal with big amounts of entities (which is why I wanted to have some details about your exact scenario). But the documentation will give you an idea.
Pascal Thivent
Code is too large to post. Can I send you to you directly, somehow?
Aaron F.
@Aaron I'd prefer some explanation with pseudo code. You can always try to post it on http://pastebin.com/, I might have a look. But I don't guarantee anything.
Pascal Thivent
Does this help any? My session steadily increases in entity count and collection count. Craps out at: 4,717 entities, 158 collections. 793MB used. Maybe this isn't a flush/cache issue, and I'm simply holding on to Hibernate object references?
Aaron F.
@Aaron Which is why I wanted to know what you're doing exactly, and how. I can't help without more details (even pseudo code). By the way,is this a standalone app?
Pascal Thivent