• 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 ...
  • Tim Cooke
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Liutauras Vilda
  • Rob Spoor
  • Junilu Lacar
  • paul wheaton
Saloon Keepers:
  • Stephan van Hulst
  • Tim Moores
  • Tim Holloway
  • Carey Brown
  • Scott Selikoff
  • Piet Souris
  • Jj Roberts
  • fred rosenberger

High Memory consumption when multiple sessionfactory is configured in dynamic web application

Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
We have a dynamic web project 3.0 using java server face 2.2 and JPA 2.1,Hibernate 4.2.3 where multiple session factory connected to multiple identical database is created using NON-JTA data source. We use multi tenancy architecture. After analyzing the heap dump of the said application, it had been seen that, each session factory is holding all entity classes of our web application which is consuming lots of memory. Lets consider the following actual running scenario for better understanding,

Our Application generate 200 session factory for 200 database. Our Application contain total 420 entity class. After analyzing heap dump it had been seen that, total 200 sessionfactory were generated which were holding instances of all 420 entity classes individually so, each session factory taking around 80 MB memory. So the total memory consumption becomes 16 GB. Which is exceptionally high consumption.

In another scenario, when we reduced no of entity from 420 to 1, then all session factory for 200 database taking memory which is minimal and acceptable for our case.

So,we think session factory consuming too much memory when we add more entity classes, our query is there any possible ways to share those entity classes between all sessionfactory or any other way is possible to reduce memory consumption ?

For your reference we are attached a heap dump screen shot for three sessionfactory.

Looking for any positive replies. Any quick replies will be greatly helpful.
[Thumbnail for Untitled.png]
Ranch Hand
Posts: 128
Hibernate Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Welcome the Ranch.  

Try using the Hibernate session which is not that memory intensive.
pie. tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
    Bookmark Topic Watch Topic
  • New Topic