[jboss-user] [JBossCache] - Possible Memory Leak? (1.4 SP7)
slattery
do-not-reply at jboss.com
Mon Dec 3 17:02:07 EST 2007
Hi all,
I'm running a test program with a simple loop that writes an object to the cache and then removes it.
As I monitor with JConsole, the heap usage grows and grows and can't be reclaimed with a garbage collection. Eventually it crashes with an OutOfMemoryError.
Below is my code.
MemoryLeakTest.java:
| package test;
|
| import static java.lang.System.out;
|
| import org.jboss.cache.PropertyConfigurator;
| import org.jboss.cache.aop.PojoCache;
|
| public class MemoryLeakTest {
|
| static PojoCache cache;
|
| public static void cacheInit() throws Exception {
| cache = new PojoCache();
| PropertyConfigurator config = new PropertyConfigurator();
| config.configure(cache, "replSync-service.xml");
| cache.start();
| }
|
|
| public static void main(String[] args) throws Exception {
| cacheInit();
|
| final int MAX = 1000000;
| final int INNER_MAX = 2;
| final int DEPTH = 0;
|
| out.println("Adding to cache...");
| for (Integer i=0; i<MAX; i++) {
| String fqn = "/" + i;
| if (i % 100 == 0) out.println(" putting at: " + fqn);
|
| for (int j=0; j<INNER_MAX; j++) {
| cache.putObject(fqn+"/"+j, new DummyObject(DEPTH));
| }
|
| for (int j=0; j<INNER_MAX; j++) {
| cache.removeObject(fqn+"/"+j);
| cache.remove(fqn+"/"+j);
| }
|
| }
|
| cacheStop();
| }
|
| public static void cacheStop() {
| cache.stop();
| cache.destroy();
| }
| }
|
|
DummyObject.java:
| package test;
|
| import java.util.ArrayList;
| import java.util.List;
| import java.util.Random;
|
| public class DummyObject {
| static Random random = new Random();
|
| byte[] data;
| List<DummyObject> children = new ArrayList<DummyObject>();
|
|
| public DummyObject(int depth) {
| this.data = new byte[100];
|
| if (depth > 0) {
| int nextDepth = depth - 1;
| children.add(new DummyObject(nextDepth));
| children.add(new DummyObject(nextDepth));
| }
| }
|
| private String generateRandomData() {
| StringBuilder sb = new StringBuilder();
| for (int i=0; i<1000; i++)
| sb.append(random.nextLong());
|
| return sb.toString();
| }
| }
|
replSync-service.xml:
| <?xml version="1.0" encoding="UTF-8"?>
| <server>
| <classpath codebase="./lib" archives="jboss-cache.jar, jgroups.jar"/>
| <mbean code="org.jboss.cache.TreeCache" name="jboss.cache:service=TreeCache">
|
| <depends>jboss:service=Naming</depends>
| <depends>jboss:service=TransactionManager</depends>
|
| <attribute name="TransactionManagerLookupClass">org.jboss.cache.DummyTransactionManagerLookup</attribute>
| <attribute name="IsolationLevel">REPEATABLE_READ</attribute>
| <attribute name="CacheMode">REPL_SYNC</attribute>
| <attribute name="UseReplQueue">false</attribute>
| <attribute name="ReplQueueInterval">0</attribute>
| <attribute name="ReplQueueMaxElements">0</attribute>
| <attribute name="ClusterName">TreeCache-Cluster</attribute>
|
| <attribute name="ClusterConfig">
| <config>
| <UDP mcast_addr="228.1.2.3" mcast_port="58866"
| ip_ttl="64" ip_mcast="true"
| mcast_send_buf_size="150000" mcast_recv_buf_size="80000"
| ucast_send_buf_size="150000" ucast_recv_buf_size="80000"
| loopback="false"/>
| <PING timeout="2000" num_initial_members="3"
| up_thread="false" down_thread="false"/>
| <MERGE2 min_interval="10000" max_interval="20000"/>
| <FD_SOCK/>
| <VERIFY_SUSPECT timeout="1500"
| up_thread="false" down_thread="false"/>
| <pbcast.NAKACK gc_lag="50" retransmit_timeout="600,1200,2400,4800"
| max_xmit_size="8192" up_thread="false" down_thread="false"/>
| <UNICAST timeout="600,1200,2400" window_size="100" min_threshold="10"
| down_thread="false"/>
| <pbcast.STABLE desired_avg_gossip="20000"
| up_thread="false" down_thread="false"/>
| <FRAG frag_size="8192"
| down_thread="false" up_thread="false"/>
| <pbcast.GMS join_timeout="5000" join_retry_timeout="2000"
| shun="true" print_local_addr="true"/>
| <pbcast.STATE_TRANSFER up_thread="true" down_thread="true"/>
| </config>
| </attribute>
|
| <attribute name="FetchInMemoryState">true</attribute>
| <attribute name="InitialStateRetrievalTimeout">15000</attribute>
| <attribute name="SyncReplTimeout">15000</attribute>
| <attribute name="LockAcquisitionTimeout">10000</attribute>
| <attribute name="EvictionPolicyClass"></attribute>
| <attribute name="UseRegionBasedMarshalling">true</attribute>
| </mbean>
|
| </server>
|
jboss-aop.xml contains:
| <?xml version="1.0" encoding="UTF-8"?>
| <aop>
| <prepare expr="field(* test.DummyObject->*)" />
| </aop>
|
I launch MemoryLeakTest with these VM parameters:
-Dcom.sun.management.jmxremote -javaagent:.\lib\jboss-aop-jdk50.jar -Djboss.aop.path=.\resources\pojocache-aop.xml -Djboss.aop.path=.\resources\jboss-aop.xml -Xms128M -Xmx128M
Is there anything obvious I might be doing wrong here?
Thanks!
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4110023#4110023
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4110023
More information about the jboss-user
mailing list