Hibernate Books

All times are UTC - 5 hours [ DST ]



Post new topic Reply to topic  [ 3 posts ] 
Author Message
 Post subject: How to fix a Hibernate memory leak
PostPosted: Wed Feb 01, 2017 8:40 am 
Newbie

Joined: Wed Feb 01, 2017 8:32 am
Posts: 2
Hello Guys ... i am facing a problm related to memory leak in my java web application.After Study the heap dump i found the Hibernate is storing cached queries with session factory instance...

select serialcyll0_.RunId as RunId1_53_0_, systemcode1_.RunID as RunID1_61_1_, systemcode2_.RunID as RunID1_62_2_, serialstat3_.RunID as RunID1_54_3_, serialcyll0_.active as active2_53_0_, serialcyll0_.Approve as Approve3_53_0_, serialcyll0_.CreatedBy as Created15_53_0_, serialcyll0_.cwtag as cwtag4_53_0_, serialcyll0_.CylinderID as Cylinder5_53_0_, serialcyll0_.emailNtyfcn as emailNty6_53_0_, serialcyll0_.isScapped as isScappe7_53_0_, serialcyll0_.IssueDateTime as IssueDat8_53_0_, serialcyll0_.ManufactDateTime as Manufact9_53_0_, serialcyll0_.replaceCount as replace10_53_0_, serialcyll0_.RFID as RFID11_53_0_, serialcyll0_.scrap as scrap12_53_0_, serialcyll0_.ScrapCount as ScrapCo13_53_0_, serialcyll0_.SerialNumber as SerialN14_53_0_, serialcyll0_.BrandRunID as BrandRu16_53_0_, serialcyll0_.PackSizeRunID as PackSiz17_53_0_, systemcode1_.Brand as Brand2_61_1_, systemcode1_.brandCreatedDate as brandCre3_61_1_, systemcode1_.CylinderType as Cylinder4_61_1_, systemcode1_.Deactive as Deactive5_61_1_, systemcode1_.i...
First 10 of 63 objects


the above is a sample of the cached queries Object's

I already disable 2 label cache . query cache even clearing session on every request but i am not able to found any solution ..

hibernate version - Hibernate-4.3.5.Final


Top
 Profile  
 
 Post subject: Re: org.hibernate.internal.sessionfactoryimpl memory leak
PostPosted: Wed Feb 01, 2017 9:10 am 
Hibernate Team
Hibernate Team

Joined: Thu Sep 11, 2014 2:50 am
Posts: 1385
Even if you enable query cache, you need to explicitly mark every query to be cached in order for Hibernate to cache an entity query.

As I explained in these 14 High-Performance Java Persistence Tips, you should not use entity queries for read-only projections. Use DTO projections instead.

If you need to select a lot of entities because you plan to modify them, you are better of using Bulk processing and let the database handle the update/delete so that you don't have to fetch the data in the data access layer.

_________________
If you liked my answer, you are going to love my High-Performance Java Persistence book and my blog as well.


Top
 Profile  
 
 Post subject: Re: How to fix a Hibernate memory leak
PostPosted: Thu Feb 02, 2017 5:26 am 
Newbie

Joined: Wed Feb 01, 2017 8:32 am
Posts: 2
Thanks for the Reply Sir ...Very helpfull !


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 3 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.