• 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

gui app not garbage collecting after hibernate finishes

 
Ranch Hand
Posts: 70
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi-

In the following two code samples, I use Hibernate and then pass the results as a ArrayList to a GUI app. The problem is as I have watched is that it doesn't release the Hibernate memory until the GUI is closed. I find it interesting that "hello world" in SWT without Hibernate is only 13,000 k of java heap memory, and my current GUI app is not much more complicated, but I can't get the computer to release the memory, until I close my GUI app. If I make it Hibernate only with no GUI the memory spikes to about 48,000k, and when the program is done running, it takes 0 memory in the taskmanager in Windows 7. If I run the GUI SWT app, memory gets as high as 55,000 k for that little app which shouldn't be so high, if the memory is released from Hibernate.

Any ideas how I can fix it, or am I stuck with it? I worked kind of hard trying to come up with this code so far and to diagnose. Maybe I can reclaim the memory somehow in my code like setting the initial heap size again right from within my code. As I understand, garbage collection reclaims heap size. GC happens when I close the SWT app. Do you find similar issues? Please help me fix it. THANKS


-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
>
 
jim mcnamara
Ranch Hand
Posts: 70
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi-

I did a little more research. I found that after the heap was increased with my hibernate code, successive calls to output the hello world SWT app and another shell did not add much at all to the heap size. So, while it didn't give all the memory back, it is good to know that it doesn't run wild and keep increasing the heap memory much when I launch other shells. It was reusing memory!

It seems that one mapping file .hbm.xml doesn't take up too much with hibernate. My reasoning would then be that each time the table is queried with createQuery, the memory would be somewhat constant as each mapping file would take relatively the same memory. This of course, if you don't load really large tables. I heard one person say their size grew to 475 mb of ram because they had a lot of mappings. That seems to blow a whole in my theory of each mapping file as relatively constant, not adding much more to the initial heap size after the first run. Since I will do small apps, that shouldn't be a problem.

I will keep checking on this later on as I write more code. It seems like it will be okay.

Very cool,
thanks

 
reply
    Bookmark Topic Watch Topic
  • New Topic