• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Hibernate 3.x and Data Dump

 
Ranch Hand
Posts: 35
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
author
Posts: 11962
5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
Ranch Hand
Posts: 35
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Then you would hit OutOfMemoryError
 
Lasse Koskela
author
Posts: 11962
5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
Ranch Hand
Posts: 35
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am pretty bad with JVM GC settings. Do you have any idea where should I begin?

Thanks.
 
On top of spaghetti all covered in cheese, there was this tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic