Eviction Using Too Much Memory?
drosenbaum Feb 10, 2006 11:21 AMHi,
I am heap profiling my application that uses JBoss Cache 1.2.4SP1 and am finding that the eviction seems to be using quite a bit of memory. In particular, here are snippets of my hprof output:
SITES BEGIN (ordered by live bytes) Fri Feb 10 09:54:18 2006 percent live alloc'ed stack class rank self accum bytes objs bytes objs trace name 1 17.58% 17.58% 13600272 17 13600272 17 49313 java.lang.Object 2 4.39% 21.97% 3400272 17 3400272 17 49300 java.lang.Object TRACE 49313: EDU.oswego.cs.dl.util.concurrent.BoundedBuffer.<init>(BoundedBuffer.java:46) org.jboss.cache.eviction.Region.createQueue(Region.java:62) org.jboss.cache.eviction.Region.<init>(Region.java:70) org.jboss.cache.eviction.RegionManager.createRegion(RegionManager.java:61) TRACE 49300: EDU.oswego.cs.dl.util.concurrent.BoundedBuffer.<init>(BoundedBuffer.java:46) org.jboss.cache.eviction.LRUAlgorithm.<init>(LRUAlgorithm.java:38) org.jboss.cache.eviction.LRUPolicy.getEvictionAlgorithm(LRUPolicy.java:122) org.jboss.cache.eviction.LRUPolicy.configure(LRUPolicy.java:225)
As you could see, in the first trace, the buffer created by the eviction Region code is allocating more than 13M of memory just for the queue. Digging further and looking at the source for org.jboss.cache.eviction.Region and EDU.oswego.cs.dl.util.concurrent.BoundedBuffer I see it is creating an Object[] array with 200000 elements!
In the 2nd trace the LRUAlgorithm class is using more than 3 megs of memory, when it allocates an Object[] array of 50000 elements.
Is eviction expected to use so much memory? Might I also suggest to change the implementation to use some kind of data structure that grows and shrinks as necessary so it would not consistently use so much memory.
Or do I somehow have eviction misconfigured? Below is a snippet of my config file:
<attribute name="EvictionPolicyClass">org.jboss.cache.eviction.LRUPolicy</attribute> <attribute name="EvictionPolicyConfig"> <config> <attribute name="wakeUpIntervalSeconds">30</attribute> <!-- Cache wide default --> <region name="/_default_"> <attribute name="maxNodes">10000</attribute> <attribute name="timeToLiveSeconds">600</attribute> </region> <region name="//net/sf/hibernate/cache/StandardQueryCache"> <attribute name="maxNodes">10000</attribute> <attribute name="timeToLiveSeconds">600</attribute> </region> </config> </attribute>
Thank you,
Daniel