[Cosmo] jackrabbit memory leak

Brian Moseley bcm at osafoundation.org
Thu Jan 5 10:04:13 PST 2006


a memory leak was just discovered in the jackrabbit query parsers.
it's not clear how bad the leaks are, but since we make extensive use
of queries in 0.3 to support caldav reports, i'll be sure to upgrade
to jackrabbit r366214.

---------- Forwarded message ----------
From: Marcel Reutegger <marcel.reutegger at day.com>
Date: Jan 5, 2006 11:40 AM
Subject: Re: Memory Leak in QueryParser?
To: jackrabbit-dev at incubator.apache.org


Hi Daniel,

you are absolutely right.

parser instances are cached using a WeakHashMap, but because the parser
itself has a strong reference to the weak key the mapping is never
released. argh... stupid me.

replaced the map implementation to a ReferenceMap with weak references
for both key and value.

same applies to the XPathQueryBuilder.

fixed in svn revision: 366214

thanks a lot for finding this issue.

regards
  marcel

Daniel Hagen wrote:
> Hi,
>
> I am currently developing a server application that uses jackrabbit as
> content repository.
> During test runs I noticed the application piling up memory even at times
> when the application only executes simple queries. I am quite (though of
> course not absolutely) sure that it is not the application itself holding
> the memory. The (web-)application uses shortlived JCR sessions, opening the
> session, executing some queries and logging out again per request, the
> repository instance itself remains in memory all the time.
>
> Running the application with -Xrunhprof:heap=sites gives some hints pointing
> in direction of the query parser (see results below).
>
> The code I use to execute the query is included below.
>
> I am using Tomcat 5.5, JDK 1.5.0_06 on Windows 2003 server, Persistence
> Manager is SimpleDbPersistenceManager connecting to a MySQL 5.0 database.
> I am using a Build of jackrabbit created on 28.12.2005.
>
> Are there any known issues concerning memory leaks?
> Are there any hints what I could do to further isolate the problem?
>
> Any help will be greatly appreciated!
>
> Regards
>
> Daniel
>
>
> Code Snippet of the function :
> ==============================
>
> QueryManager queryManager = session.getWorkspace().getQueryManager();
> Query query = queryManager.createQuery( queryText, Query.SQL );
> QueryResult queryResult = query.execute();
> return queryResult;
> [ return queryresult, logout from session ... ]
>
>
> HPROF Excerpt:
> ==============
>
> SITES BEGIN (ordered by live bytes) Thu Jan 05 15:44:55 2006
>           percent          live          alloc'ed  stack class
>  rank   self  accum     bytes objs     bytes  objs trace name
>     1 17.55% 17.55%   5936800  362   5936800   362 329857 int[]
>     2 17.55% 35.09%   5936800  362   5936800   362 329856 int[]
>     3  8.78% 43.88%   2971296  362   2971296   362 329855 char[]
>     4  2.01% 45.88%    679328 21229   5142240 160695 318751
> org.apache.commons.collections.map.AbstractReferenceMap$WeakRef
>     5  1.56% 47.45%    528888   86   2053592   148 331237 byte[]
>
> TRACE 329857:
>
> org.apache.jackrabbit.core.query.sql.SimpleCharStream.<init>(SimpleCharStrea
> m.java:263)
>
> org.apache.jackrabbit.core.query.sql.SimpleCharStream.<init>(SimpleCharStrea
> m.java:269)
>
> org.apache.jackrabbit.core.query.sql.JCRSQLParser.<init>(JCRSQLParser.java:1
> 132)
>
> org.apache.jackrabbit.core.query.sql.JCRSQLQueryBuilder.createQuery(JCRSQLQu
> eryBuilder.java:127)
>
> TRACE 329856:
>
> org.apache.jackrabbit.core.query.sql.SimpleCharStream.<init>(SimpleCharStrea
> m.java:262)
>
> org.apache.jackrabbit.core.query.sql.SimpleCharStream.<init>(SimpleCharStrea
> m.java:269)
>
> org.apache.jackrabbit.core.query.sql.JCRSQLParser.<init>(JCRSQLParser.java:1
> 132)
>
> org.apache.jackrabbit.core.query.sql.JCRSQLQueryBuilder.createQuery(JCRSQLQu
> eryBuilder.java:127)
>
> TRACE 329855:
>
> org.apache.jackrabbit.core.query.sql.SimpleCharStream.<init>(SimpleCharStrea
> m.java:261)
>
> org.apache.jackrabbit.core.query.sql.SimpleCharStream.<init>(SimpleCharStrea
> m.java:269)
>
> org.apache.jackrabbit.core.query.sql.JCRSQLParser.<init>(JCRSQLParser.java:1
> 132)
>
> org.apache.jackrabbit.core.query.sql.JCRSQLQueryBuilder.createQuery(JCRSQLQu
> eryBuilder.java:127)
>
>
>


--
-----------------------------------------< marcel.reutegger at day.com >---
Marcel Reutegger, Day Software AG, Barfuesserplatz 6, CH - 4001 Basel
T +41 61 226 98 98, F +41 61 226 98 97
-----------------------------------------------< http://www.day.com >---



More information about the Cosmo mailing list