You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@isis.apache.org by "Dan Haywood (JIRA)" <ji...@apache.org> on 2015/04/23 19:36:40 UTC

[jira] [Resolved] (ISIS-1134) DN connections leak due to non-closed queries (?!)

     [ https://issues.apache.org/jira/browse/ISIS-1134?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Dan Haywood resolved ISIS-1134.
-------------------------------
    Resolution: Fixed

> DN connections leak due to non-closed queries (?!)
> --------------------------------------------------
>
>                 Key: ISIS-1134
>                 URL: https://issues.apache.org/jira/browse/ISIS-1134
>             Project: Isis
>          Issue Type: Bug
>          Components: Core
>    Affects Versions: core-1.8.0
>            Reporter: Martin Grigorov
>            Assignee: Dan Haywood
>
> My application failed twice with OutOfMemoryError in heap space so I've dumped a .hprof of its memory (jmap -dump:format=b,file=some-file.hprof) and analyzed it with Eclipse MAT (https://eclipse.org/mat/).
> It appears that there are many org.datanucleus.store.rdbms.query.JDOQLQuery$2 objects.
> JDOQLQuery$2 appears to be ManagedConnectionResourceListener ( https://github.com/datanucleus/datanucleus-rdbms/blob/651c77ff3b2af76ada97d14b537cd41fb0524a0c/src/java/org/datanucleus/store/rdbms/query/JDOQLQuery.java#L740).
> The listener is removed only when org.datanucleus.store.query.AbstractQueryResult#close() method is called.
> org.apache.isis.objectstore.jdo.datanucleus.persistence.queries.PersistenceQueryFindAllInstancesProcessor#process() does:
> {code}
> final List<?> pojos = (List<?>) jdoQuery.execute();
> return loadAdapters(specification, pojos);
> {code}
> So it consumes the result and returns ObjectAdapter for each pojo but it doesn't close the Query.
> AFAIK open-session-in-view pattern is not used in Isis so the resources should be closed explicitly after usage.
> A simple solution is to try/finally this code and close the query but I may miss some detail here.
> Related: recently I've profiled the application with Yourkit and it showed that DomainObjectContainer#allMatches() method is slow in one of the use cases. Some quick investigation showed that DomainObjectContainer delegates the work to org.apache.isis.objectstore.jdo.datanucleus.persistence.queries.PersistenceQueryProcessor#process(). It loads the POJOs from the DB, then wraps them in ObjectAdapters, and finally org.apache.isis.core.metamodel.services.container.DomainObjectContainerDefault#allMatches(org.apache.isis.applib.query.Query<T>) unwraps them back to POJOs.
> Why this is done?
> This solves the issue of "consume the QueryResult before closing it" for the memory leak issue but it also adds to the processing time.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)