• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Hibernate session objects

 
Nilesh Shekokar
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all,
I wanted to know about the Hibernate Session Objects
In my project there are many Hibernate session objects created
for getting the connectoion. But they are not closed?
Are the objects Lightweight??
Because i am facing some memory consumption problem.The Hibernate objects
can be one of the issue.
So i wanted to know that should i close all the session objects??
If they are lightweight how much memory would they occupy?
Waiting for reply soon.

Thank you.
 
pascal betz
Ranch Hand
Posts: 547
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You need to close the Session after you are done using it.

The Session keeps track of entities associated with it as well as the DB Connection. So if you do not clean up properly you might prevent a lot of Objects from beeing garbage collected. It's hard to tell how much memory they will use because the size depends on how many (unused) Objects are beeing held by the Session.

But anyway you should absolutely close the Session (try/finally)

What do you mean by "for getting the connectoion" ?
Do you get the underlying JDBC connection from the Session ?


Pascal
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic