• 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: OutOfMemory Error!

 
Ranch Hand
Posts: 58
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi!everyone,
I use Hibernate + JBX to wirte a piece of code.Here is my code:



But when running, it is also a OutOfMemory Error. What's your opinion?

Thanks for help!


Regard,

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

the reason for OutOfMemory is not Hibernate ! its your strange way of splitting the input string...once you enter the do-while loop the index i is never incremented so you are looking at the same character over and over... you will create an huge StringBuffer ...

- for splitting the Input String: Check out StringTokenizer or String.split() method added in 1.4

- why is there UserInfo and Data class ? you retrieve UserInfo Objects from your query ?


- Make sure always to close your Session/end Transaction (also in the case of an Exception). use try/catch/finally !

you can find more on this here:
http://www.hibernate.org/hib_docs/reference/en/html/manipulatingdata.html#manipulatingdata-endingsession-exceptions


- your OperateDB class is not Thread Safe (e.g. Transaction is a member variable)

- You should not create the SessionFactory every time the updateData method is called (SessionFactory is an expensive Object to create). Create it once and then just retrieve Session Objects from your SessionFactory every call to updateData

- have a look at saveOrUpdate() method in Session

- if you just want to retrieve one result (if you have the ID) you can use something like that

here is the API:
API

cheers

pascal
[ August 20, 2004: Message edited by: pascal betz ]
 
George Ren
Ranch Hand
Posts: 58
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Pascal,thank you very much for such a fantastic help! I think I have figured out that problem.

Wish you a nice day!
 
You totally ruined the moon. You're gonna hafta pay for that you know. This tiny ad agrees:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic