You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@openjpa.apache.org by Roger Keays <ro...@ninthavenue.com.au> on 2006/10/31 01:28:00 UTC
cached byte[] consumes excessive memory
Hi all,
I am experimenting with serving blobs from a database with JPA and have
noticed that, when caching is enabled, OpenJPA uses significantly more
memory than you would expect to cache the blob. For example, a 7MB
byte[] consumes over 120MB of memory when cached.
My profiler shows me that this memory is being consumed by 1 or 2 very
large Object[] s created by the ArrayList used to cache the byte[] in
org.apache.openjpa.kernel.AbstractPCData.toData(). I can't see anything
obviously wrong with the code there and the value of the length variable
seems to be correct.
Perhaps somebody else might know what is going on here? The stacktrace
which produced this memory blowout is attached as a .png.
Thanks,
Roger
--
----------------------------------------
Ninth Avenue Software
p: +61 7 3137 1351 (UTC +10)
f: +61 7 3102 9141
w: http://www.ninthavenue.com.au
e: info@ninthavenue.com.au
----------------------------------------
Re: cached byte[] consumes excessive memory
Posted by Abe White <aw...@bea.com>.
AbstractPCData needs to be modified to special-case primitive arrays
to just copy the array and cache it is an opaque value, rather than
using a List where each element is a potentially separately-cached
instance. Roger, I'd encourage you to file a JIRA issue for this
problem.
p.s. In case it isn't obvious, the memory blowup is due to creating 7
million Byte wrapper objects to store in the List -- one for each
byte in the array.
Re: cached byte[] consumes excessive memory
Posted by Roger Keays <ro...@ninthavenue.com.au>.
> Perhaps somebody else might know what is going on here? The stacktrace
> which produced this memory blowout is attached as a .png.
http://mong.geckohosting.com.au/~roger/tmp/blob-stacktrace.png
--
----------------------------------------
Ninth Avenue Software
p: +61 7 3137 1351 (UTC +10)
f: +61 7 3102 9141
w: http://www.ninthavenue.com.au
e: info@ninthavenue.com.au
----------------------------------------