Announcement Announcement Module
Collapse
No announcement yet.
Possible memory leak -org.hibernate.impl.SessionFactoryImpl Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • 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
    AnujAttachment Attachment
    Attached Files

  • #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

    Comment


    • #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

      Comment


      • #4
        I am also facing the same issue. are you able to solve this issue?

        Comment


        • #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.

          Comment

          Working...
          X