-
Jun 17th, 2011, 11:55 PM
#1
Possible memory leak -org.hibernate.impl.SessionFactoryImpl
I am having a spring hibernate webapplication which runs on jboss server. I have noticed JVM Free memory decreasing drastically in a weeks time since i start the server .
and jvm thread count goes up. I have run heap dump on eclipse memory analyzer and it list -org.hibernate.impl.SessionFactoryImpl as prime suspect . My application connect to three different database and hence having three sessionFactories. Can anybody tell me why this happens
Thanks & Regards
Anujmemanalyze21.jpgmemanalyze1.jpg
-
Jun 19th, 2011, 02:10 PM
#2
Hello
If you could post each SessionFactory would be nice, I guess you are working with Pools for each DB, Am I correct?, furthermore I could assume that some special parameters for your jboss server are setting, like Tomcat for example about the heap sizes
- Manuel Jordan
Kill Your Pride, Share Your Knowledge With All
The Fear Of The LORD Is The Beginning Of Knowledge, But Fools Despise Wisdom And Discipline. Proverbs 1:7
Blog
Technical Reviewer of Apress
- Pro SpringSource dm Server
- Spring Enterprise Recipes: A Problem-Solution Approach
- Spring Recipes: A Problem-Solution Approach, 2nd Edition
- Pro Spring Integration
- Pro Spring Batch
- Pro Spring 3
- Pro Spring MVC: With Web Flow
- Pro Spring Security
-
Jun 20th, 2011, 11:15 PM
#3
Hello,
thank you for the reply.
Follwing is the structure of my sessionFactory
<bean id="sessionFactoryRefOne"
class="org.springframework.orm.hibernate3.LocalSes sionFactoryBean">
<property name="dataSource">
<ref bean="dataSourceRefOne" />
</property>
<property name="mappingResources">
<list>
<value>com/gen/generic.hbm.xml</value>
<value>com/gen/trasact.hbm.xml</value>
</list>
</property>
<property name="hibernateProperties">
<props>
<prop key="hibernate.dialect">
org.hibernate.dialect.PostgreSQLDialect
</prop>
<prop key="hibernate.show_sql">true</prop>
<prop key="hibernate.cache">false</prop>
<!-- <prop key="hibernate.cache.use_query_cache">true</prop> -->
<prop key="hibernate.cglib.use_reflection_optimizer">fal se</prop>
<prop key="cache.provider_class">org.hibernate.cache.NoC acheProvider</prop>
<prop key="hibernate.cache.use_second_level_cache">false </prop>
</props>
</property>
</bean>
I have two other similar sessionfactory defined in my application each refering a different datasource. datasource is managed by jboss itself.
in jboss i've given xms and xmx as 3GB.
Thank & Regards
Anuj
-
Feb 4th, 2013, 10:28 AM
#4
I am also facing the same issue. are you able to solve this issue?
-
Feb 8th, 2013, 10:30 AM
#5
I am able to fix the issue. The following is the root cause:
Starting from Spring 1.2.6 release, this default connection release mode changed from ‘auto’ to ‘close’ while using LocalSessionFactoryBean. So spring sets this mode to "on_close" instead of "auto".
As per spring specification at http://static.springsource.org/sprin...ctoryBean.html
"Note that this factory will use "on_close" as default Hibernate connection release mode, unless in the case of a "jtaTransactionManager" specified, for the reason that this is appropriate for most Spring-based applications (in particular when using Spring's HibernateTransactionManager). Hibernate 3.0 used "on_close" as its own default too; however, Hibernate 3.1 changed this to "auto" (i.e. "after_statement" or "after_transaction"). "
How to Fix It:
You can fix this issue by overriding the property <prop key="hibernate.connection.release_mode">after_stat ement</prop> under sessionFactory hibernate settings. you can set the value to after_statement/auto/after_transaction.
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules