Hibernate version:
2.1.6
Name and version of the database you are using:
SQLServer2000 ( jTDSDriver )
I have a problem when trying to select all rows from a large table ( 1.5 million rows ). Doing a simple find( "from MyObject" ) seems will run into garbage collection problems as the combined temporary overhead of hibernate and the JDBC driver uses a lot of memory which needs to be garbage collected regularly. I set my VM options to min and max memory of 1gig and I see this behaviour.
Start fines, CPU maxes out as rows are retrieved.
JVM hits the 1gig limit ( combined JDBC, hibernate and return objects ) so it runs a GC to cleanup some room.
Runs for a bit longer at max CPU then hits the mem limit and GCs again.
And so on until all the rows come back.
This takes approximate 10 mins to run because of all the garbage collection that is required ( the used space at the end is only 150meg ) so I was wondering if ScrollableResults would solve this problem without a performance penalty. Something like...
Code:
Query q = session.createQuery( "from MyObject" );
ScrollableResults sr = q.scroll();
// loop over scrollable results....
while ( sr.next() )
{
Object[] row = sr.get();
// process row
}
Is there any way of getting the MyObject back out of a scrollable results or is it always a flat array like JDBC?
Cheers.