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

gui app not garbage collecting after hibernate finishes

 
jim mcnamara
Ranch Hand
Posts: 70
  • Mark post as helpful
  • send pies
  • 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
  • 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

 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic