• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How can Hibernate cause an Out of Memory Exception?

 
Thony Anthony
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
We have an application that handles parsing of a file from 1 format to another. It uses hibernate to access the database and retrieve the parameters for its parsing. Basically whenever a user saves a file in our file folder the application will automatically retrieve that file and parse it to the corresponding file format. Lately we've began encountering out of memory exception with our application and using the dump file it produces after the server breakdown we consulted the IBM people for help and this was there findings.

Leak suspect [1]
The leak suspect root org/hibernate/impl/SessionFactoryObjectFactory is responsible for 65% of the total Java heap. It has 1,406 references to the type: java/util/HashMap$Entry. Please review the object org/hibernate/impl/SessionFactoryObjectFactory to assess how much Java heap is required by the object.

Suspected memory leaking regions:
Owner chain - Dominator tree:
org/springframework/orm/hibernate3/LocalSessionFactoryBean static, class0x469fa350, reaches: 661,877,753 bytes
|org/hibernate/cfg/Configuration static, class0x46b591d8, reaches: 661,816,601 bytes
|-org/hibernate/impl/SessionFactoryImpl static, class0x47121ba8, reaches: 661,807,895 bytes
|--org/hibernate/impl/SessionFactoryObjectFactory static, class0x4710f040, reaches: 661,804,533 bytesLEAK_ROOT <------ Object suspected of leaking
|---org/hibernate/util/FastHashMap, object0x2cb1428, reaches: 661,804,111 bytes
|----java/util/HashMap, object0x3ef5fb10, reaches: 661,804,107 bytes
|-----java/util/HashMap$Entry[ ], array0x3ef5fb40, reaches: 661,804,071 bytesLEAK_CONTAINER <------ Object holding the leaking objects

|------Leaking unit:
|-------java/util/HashMap$Entry, object0x3ef69310, reaches: 9,612,229 bytes
|-------java/util/HashMap$Entry, object have grown by 1,406 instances
|--------org/hibernate/impl/SessionFactoryImpl, object

The leak suspect is a class of type: org/hibernate/impl/SessionFactoryObjectFactory
The leak suspect size is: 662MB
The object the leak suspect is holding that contains leaking objects is a class of type: java/util/HashMap$Entry[]
The object the leak suspect is holding that contains leaking objects has a size of: 662MB
The object that is suspected to be leaking is a class of type: java/util/HashMap$Entry
The object that is suspected to be leaking has a size of: 10MB
The object that is suspected to be leaking occurs: 1,406 times.

We have no idea how can Hibernate hash map will cause this much of heap size consumption. Anyone help please.... ^_^
 
Paul Sturrock
Bartender
Posts: 10336
Eclipse IDE Hibernate Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Why do you think this is a leak? Is it exhibiting leak behaviour? The sesson factory is pretty central to everything Hibernate does and I'm not aware of memory leaks in it. There is certainly nothing in the Hibernate JIRA.

My guess is this is something about how you use Hibernate not Hibernate itself. Can you post your code?

 
Thony Anthony
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This is just a code snippet of the app..


public List getInputTemplates() throws DataException {
List list = getHibernateTemplate().find("from InputTemplate");

Iterator iter = list.iterator();

while(iter.hasNext()){
InputTemplate it = (InputTemplate)iter.next();

List tmplList = getHibernateTemplate().find("from InputOutputTemplateMap where inpTmplID=" + it.getInpTmplID());

if(tmplList.size() != 0) {
it.setInputOutputTemplateMapList(tmplList);
}
}

getHibernateTemplate().flush();

return list;
}
 
Paul Sturrock
Bartender
Posts: 10336
Eclipse IDE Hibernate Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Is there no relationship between InputTemplate and InputOutputTemplateMap? Why are you doing this with two queries? And how much data is in InputTemplate?
 
Thony Anthony
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
inputOutputTemplateMap is the table containing the mapping for the inputTemplate to its corresponding outputtemplate. Then the inputTemplate holds less than 100 records.
 
Paul Sturrock
Bartender
Posts: 10336
Eclipse IDE Hibernate Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Fair enough. Do you ever close your Sessions? Or just flush them?
 
Thony Anthony
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
just flush.. is there any other part we need to close?
 
Thony Anthony
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
can anyone have any idea about this? please help
 
Jimmy Clark
Ranch Hand
Posts: 2187
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
...we consulted the IBM people for help and this was there findings.


How did the IBM people come up with "there" findings?
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic