Please help in solving the memory issue in the Spring MVC application
Please find my transaction configurations
<bean id="dataSource" class="com.mchange.v2.c3p0.ComboPooledDataSource"
destroy-method="close" p:driverClass="${jdbc.driverClassName}"
p:jdbcUrl="${jdbc.databaseurl}${jdbc.encoding}" p:user="${jdbc.username}" p:password="${jdbc.password}"
p:minPoolSize="${minPoolSize}" p:maxPoolSize="${maxPoolSize}"
p:checkoutTimeout="${checkoutTimeout}" p:maxIdleTime="${maxIdleTime}"
p:idleConnectionTestPeriod="${idleConnectionTestPeriod}" />
jdbc:
minPoolSize=15
initalPollSize=25
maxPoolSize=60
#Give up waiting for a connection after this many milliseconds
checkoutTimeout=18000
maxIdleTime=3600
idleConnectionTestPeriod=300
maxStatements=100
numHelperThreads=15
acquireIncrement=10
<!--session factory -->
<bean id="sessionFactory"
class="org.springframework.orm.hibernate4.LocalSessionFactoryBean">
<property name="dataSource" ref="dataSource" />
<property name="hibernateProperties">
<props>
<prop key="hibernate.dialect">${jdbc.dialect}</prop>
<prop key="hibernate.show_sql">false</prop>
<prop key="hibernate.generate_statistics">false</prop>
</props>
</property>
<property name="entityInterceptor" ref="auditInterceptor">
</property>
</bean>
<!-- transaction manager -->
<bean id="transactionManager"
class="org.springframework.orm.hibernate4.HibernateTransactionManager">
<property name="sessionFactory" ref="sessionFactory" />
</bean>
<!-- transaction interveptor -->
<bean id="transactionInterceptor"
class="org.springframework.transaction.interceptor.TransactionInterceptor">
<property name="transactionManager" ref="transactionManager" />
</bean>
<bean class="org.springframework.aop.framework.autoproxy.BeanNameAutoProxyCreator">
<property name="beanNames">
<list>
<value>*Service</value>
</list>
</property>
<property name="interceptorNames">
<list>
<value>exceptionInterceptor</value>
<value>transactionInterceptor</value>
</list>
</property>
</bean>
After the performance test my memory is not getting released.So when analysed the heap dump got the below error
One instance of "org.hibernate.internal.SessionFactoryImpl" loaded by "org.apache.catalina.loader.WebappClassLoader @ 0x76000b8e8" occupies 73,446,008 (32.66%) bytes. The memory is accumulated in one instance of "org.hibernate.internal.util.collections.BoundedConcurrentHashMap$Segment[]" loaded by "org.apache.catalina.loader.WebappClassLoader @ 0x76000b8e8".
org.hibernate.internal.SessionFactoryImpl @ 0x7624efeb0 136 49,987,288 34.31% \org.hibernate.engine.query.spi.QueryPlanCache @ 0x7630b1250 32 47,674,176 32.72% .\org.hibernate.internal.util.collections.BoundedConcurrentHashMap @ 0x763259a58 48 47,554,336 32.64% ..\org.hibernate.internal.util.collections.BoundedConcurrentHashMap$Segment[32] @ 0x7632d1c60 144 47,554,288 32.64%
org.hibernate.internal.util.collections.BoundedConcurrentHashMap$Segment[32] @ 0x7632d1c60 | 144 | 47,554,288 | 32.64% |- org.hibernate.internal.util.collections.BoundedConcurrentHashMap$Segment @ 0x76325ac88 | 48 | 1,497,688 | 1.03% |- org.hibernate.internal.util.collections.BoundedConcurrentHashMap$Segment @ 0x76325ac58 | 48 | 1,631,272 | 1.12% | |- org.hibernate.internal.util.collections.BoundedConcurrentHashMap$LIRSHashEntry @ 0x768fd54c0 | 56 | 880 | 0.00% | | |- org.hibernate.engine.query.spi.sql.NativeSQLQuerySpecification @ 0x7671eb8e8 | 32 | 48 | 0.00% | | | '- org.hibernate.engine.query.spi.sql.NativeSQLQueryReturn[0] @ 0x768ff16d0 | 16 | 16 | 0.00% | | |- org.hibernate.engine.query.spi.NativeSQLQueryPlan @ 0x768ff1640 | 24 | 520 | 0.00%
column FROM table WHERE column IN (94316) | 24 | 256 | 0.00%Please help to solve the issue
We observed a query in heap.
from table where statusFlg='Y' and deleteFlg='N' and id="+autoGeneratedId
and when we changed the query to
from table where statusFlg='Y' and deleteFlg='N' and id= :instanceid").setParameter("instanceId,autoGeneratedId)
the session objects are getting garbage collected.
Can some one explain in deail
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With