Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Hibernate 3.x and Data Dump

 
T H Lim
Greenhorn
Posts: 28
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I have a web application using Hibernate 3.x and allow users to download 28k++ database rows as a CSV file for reporting purposes. What I did was read all the rows as objects, extracted each attributes and write each value out to the output stream as CSV. Using this method, my JVM memory footprint increased by 40MB or more. What I want is to able to reduce the footprint increment to 10MB or less because the process is pretty straight forward. The rows has no relationship with each other i.e. the next row need not refer to the previous row which can be discarded after writing to the output stream. How do I make Hibernate do that?

I have tried using iterator as in

getSession().createQuery("from Customer c").iterate();

Or anyone can suggest a better way to do this? Please advise.

Thank you.
 
Lasse Koskela
author
Sheriff
Posts: 11962
5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Maybe those objects aren't garbage collected because the JVM doesn't need to free up that memory? What happens if you give a smaller heap to the JVM?
 
T H Lim
Greenhorn
Posts: 28
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Then you would hit OutOfMemoryError
 
Lasse Koskela
author
Sheriff
Posts: 11962
5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Are you sure? How low did you set it?

What I'm after is that the JVM might be using up that 40 megabytes because it has no reason not to. If that's the case, you're probably better off tweaking the JVM garbage collection algorithm, not your code.
 
T H Lim
Greenhorn
Posts: 28
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am pretty bad with JVM GC settings. Do you have any idea where should I begin?

Thanks.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic