I wrote this simple program:
Code:
public static void main(String[] args) throws Exception {
Session s = HibernateUtil.getSession();
ScrollableResults scr = s.createCriteria(Match.class).setCacheMode(CacheMode.IGNORE).scroll(ScrollMode.FORWARD_ONLY);
s.close();
}
This program fails to run with OutOfMemoryException. After setting jvm parameter to -Xmx128m, I was able to run the program. Execution of second line of code increases the program memory from 18M to 110M. I havent even begun scrolling the ResultSet and the memory consumption has gone up drastically.
The table backing the class is not too big ~ 5000 rows. Some might argue that I am fetching too much data into memory, but I am using the ScrollableResults interface and it should fetch data like a JDBC ResultSet.
I examined the first level session cache via SessionStatistics object after line 2, it had 0 entites and collection. Where is all the memory being consumed? I havent enabled second-level cache.
This is with MySQL database version 5.0.27 with 5.0.4 JDBC conncetor from MySQL and Hibernate 3.2
Thanks
Avneesh