jackrabbit-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "amuthmann@dev-eth0.de" <amuthm...@dev-eth0.de>
Subject Possible Memory-Leak in IdURICache
Date Mon, 17 Dec 2012 08:42:21 GMT
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Hi there,

we recently discovered a potential memory-leak in
org.apache.jackrabbit.spi2dav.IdURICache

It is possible to flood your heap space if you only issue reading
operations into the repository. The IdURICache caches both "id to uri"
and "uri to id" calls inside of two HashMaps. Those HashMaps are
cleared if you e.g. start a move operation. Otherwise those Maps are
just filled with new data.

We fixed this by changing the type to an LRU cache with a maximum
size. This can be done by using a LinkedHashMap and override the
removeEldestEntry method.

@Override
protected boolean removeEldestEntry(Map.Entry<ItemId, String> eldest){
  return this.size() > MAXSIZE;
}

The maximum size can be a fixed value or change depending on your
memory. We estimated the size of a single cached element as <<1K and
set the Cachesize to Runtime.getRuntime().freeMemory() / 1000, which
works quite well in our project.

Probably somebody could validate this issue or (if this is no problem)
give us a hint, how to work around the problem without changing the
IdURICache class.


Greetings.

- -- 
Mit freundlichen Grüßen,

Alexander Muthmann
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.19 (MingW32)
Comment: Using GnuPG with undefined - http://www.enigmail.net/

iQEcBAEBAgAGBQJQztrqAAoJECZ7B+yLtUl+6t4H/1WW8soLqPENHSItNLEFQzwm
VwBuR6vNy2Lzg0F1/wbNH2oGTD7k5ZajJ+w0gL6WYsgh4JEcA3qRsjZgJ+GZQ+LW
Gh0wJa6idYozWlSg5RmfxnozTpoogad0+PlDzljiITCM076Bx3NcgBqz8ReKdQ//
Gslm3KwBfPADVfKb++6Z539r9tgMQUt6jai8sSTLhQHmOCHFtSFUMBEemEiKdfNN
lZaTd6uQvNpqZKNU9JlpgAMIh8TLmY4LDacSK+TQvaCygVIdS7UYmrUGaczzzf36
oOBow0zAsakUungxCT9yG6sc+vvppyTMaLv1e+ZnhmS3EDMbaaw8WnxN2WtX8wM=
=1nQ0
-----END PGP SIGNATURE-----

Mime
View raw message