• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Memory usage in Hibernate SessionFactory

 
VedaMurthy Murthy
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
After initializing a Hibernate SessionFactory with over 800 mapping files, I profile my application and see that the SessionFactoryImpl is holding onto 475MB memory (mostly in the form of Strings and char[]). Is there any way to reduce this? In particular, is there a way for some of this memory be allocated when that particular entity/mapping is accessed so that an application which only access a subset of the entity types won't load all of the mappings?

This problem was bad in hibernate 3.3.1 (225MB) but has gotten ridiculous in hibernate3.5 (475MB).

 
Paul Sturrock
Bartender
Posts: 10336
Eclipse IDE Hibernate Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
No. Is the memory foot print causing a problem?
 
VedaMurthy Murthy
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes it is causing quite a large problem. Some users of the application are only using a very small set of the functionality and yet they need to allocate 595MB just for the hibernate SessionFactoryImpl memory footprint. At this point their machines don't have enough memory to run the application.
 
Paul Sturrock
Bartender
Posts: 10336
Eclipse IDE Hibernate Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Well 800 mapped entities is quite a lot, so Hibernate is going to do a fair bit when it configures the SessionFactory. The only solution I can think of (if increasing the heap is not possible) is to break your application out in to multiple SessionFactories, assuming your application can support this sort of compartmentalization? Quite a heavy duty and intrusive fix though. It might be more prudent to just get those purchase orders in for more RAM.
 
Arun Kumarr
Ranch Hand
Posts: 661
Eclipse IDE Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Can we not deploy hibernate as a service, bind the session factory to JNDI in the app server?
Application code can look up only when necessary.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic