[hibernate-issues] [Hibernate-JIRA] Commented: (HHH-5215) SQLQueryImpl Memory Leak causes OutOfMemoryException

Pamir Erdem (JIRA) noreply at atlassian.com
Tue May 11 15:58:24 EDT 2010


    [ http://opensource.atlassian.com/projects/hibernate/browse/HHH-5215?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=37048#action_37048 ] 

Pamir Erdem commented on HHH-5215:
----------------------------------

If you put a breakpoint on org.hibernate.engine.query.sql.NativeSQLQuerySpecification.NativeSQLQuerySpecification's constructor you can see that, hashCode which is always calculated different from the previous one for the same native query is the problem. (ArrayHelper.toList which produces different hashCodes for the same query)
!hashCode.jpg!

By looking at stack trace you can easily see that 
org.hibernate.engine.query.QueryPlanCache/getNativeSQLQueryPlan -> (calls) | org.apache.commons.collections.map.AbstractReferenceMap.put->(because it calls it's super)org.apache.commons.collections.map.AbstractHashedMap.put method is executed.

The reason of the problem is, putting elements which inherent getHashCode and equals methods from object class, into HashMap, jvm to increase the usable memory size till jvm throws OutOfMemoryException

> SQLQueryImpl Memory Leak causes OutOfMemoryException
> ----------------------------------------------------
>
>                 Key: HHH-5215
>                 URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-5215
>             Project: Hibernate Core
>          Issue Type: Bug
>    Affects Versions: 3.3.2
>         Environment: Sun Solaris 10 Sparc
>            Reporter: Pamir Erdem
>         Attachments: hashCode.jpg, nativequeryspec.jpg, Query.jpg, sameQueryOutGoingRef.jpg
>
>
> In one of our batch operations gets OutOfMemoryExcetion. Working on heap dump, it is found out that, same query cached  more than once.
> In the picture below the query is shown.
> !Query.jpg!
> After we found out that the root cause of the problem is the QueryPlanCache, the batch was executed under eclipse environment to find what was wrong.
> Altough the only qery is the query.jpg the query plan cache was so high that it can be  seen easly from MAT.
> !nativequeryspec.jpg!
> We get the picture below by going outgoing references from MAT.
> !sameQueryOutGoingRef.jpg!
> From debugging view of eclipse, we want to produce the problem step by step to prove the heap dump.
> The first step was looking at the source code where hashCode was calculated.
> !!

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://opensource.atlassian.com/projects/hibernate/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        


More information about the hibernate-issues mailing list