You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@commons.apache.org by ha...@apache.org on 2002/03/27 21:54:55 UTC

cvs commit: jakarta-commons-sandbox/altrmi/src/java/org/apache/commons/altrmi/test MemoryLeak.java MemoryLeakClientTest.java MemoryLeakImpl.java

hammant     02/03/27 12:54:55

  Modified:    altrmi/src/java/org/apache/commons/altrmi/test
                        MemoryLeak.java MemoryLeakClientTest.java
                        MemoryLeakImpl.java
  Log:
  improved memory leak tests
  
  Revision  Changes    Path
  1.2       +2 -0      jakarta-commons-sandbox/altrmi/src/java/org/apache/commons/altrmi/test/MemoryLeak.java
  
  Index: MemoryLeak.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons-sandbox/altrmi/src/java/org/apache/commons/altrmi/test/MemoryLeak.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- MemoryLeak.java	27 Mar 2002 13:32:40 -0000	1.1
  +++ MemoryLeak.java	27 Mar 2002 20:54:55 -0000	1.2
  @@ -10,4 +10,6 @@
   public interface MemoryLeak {
   
       MemoryLeak getNewMemoryLeak();
  +    String getHugeString();
  +
   }
  
  
  
  1.2       +3 -2      jakarta-commons-sandbox/altrmi/src/java/org/apache/commons/altrmi/test/MemoryLeakClientTest.java
  
  Index: MemoryLeakClientTest.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons-sandbox/altrmi/src/java/org/apache/commons/altrmi/test/MemoryLeakClientTest.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- MemoryLeakClientTest.java	27 Mar 2002 13:32:40 -0000	1.1
  +++ MemoryLeakClientTest.java	27 Mar 2002 20:54:55 -0000	1.2
  @@ -26,7 +26,7 @@
    *
    *
    * @author Paul Hammant <a href="mailto:Paul_Hammant@yahoo.com">Paul_Hammant@yahoo.com</a>
  - * @version $Revision: 1.1 $
  + * @version $Revision: 1.2 $
    */
   public class MemoryLeakClientTest {
   
  @@ -43,9 +43,10 @@
   
           for (int i = 0; i < 100000000; i++) {
               MemoryLeak tmpMl = ml.getNewMemoryLeak();
  +            ml.getHugeString();
   
               System.gc(); // pointless ?
  -            if (("" + i).endsWith("000")) {
  +            if (i%100 == 0) {
                   long end = System.currentTimeMillis();
                   System.out.println("Iter "
                           + i + ", "
  
  
  
  1.2       +49 -1     jakarta-commons-sandbox/altrmi/src/java/org/apache/commons/altrmi/test/MemoryLeakImpl.java
  
  Index: MemoryLeakImpl.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons-sandbox/altrmi/src/java/org/apache/commons/altrmi/test/MemoryLeakImpl.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- MemoryLeakImpl.java	27 Mar 2002 13:32:40 -0000	1.1
  +++ MemoryLeakImpl.java	27 Mar 2002 20:54:55 -0000	1.2
  @@ -1,3 +1,4 @@
  +
   /*
    * Copyright (C) The Apache Software Foundation. All rights reserved.
    *
  @@ -7,10 +8,57 @@
    */
   package org.apache.commons.altrmi.test;
   
  +
  +
  +/**
  + * Class MemoryLeakImpl
  + *
  + *
  + * @author Paul Hammant <a href="mailto:Paul_Hammant@yahoo.com">Paul_Hammant@yahoo.com</a>
  + * @version $Revision: 1.2 $
  + */
   public class MemoryLeakImpl implements MemoryLeak {
   
  +    private String mHugeStr = "";
  +
  +    /**
  +     * Constructor MemoryLeakImpl
  +     *
  +     *
  +     */
  +    MemoryLeakImpl() {
  +
  +        StringBuffer sb = new StringBuffer();
  +
  +        for (int i = 0; i < 1000; i++) {
  +            sb.append("" + i);
  +        }
  +
  +        mHugeStr = sb.toString();
  +    }
  +
  +    /**
  +     * Method getNewMemoryLeak
  +     *
  +     *
  +     * @return
  +     *
  +     */
       public MemoryLeak getNewMemoryLeak() {
  -        System.gc(); // pointless ?
  +
  +        System.gc();    // pointless ?
  +
           return new MemoryLeakImpl();
  +    }
  +
  +    /**
  +     * Method getHugeString
  +     *
  +     *
  +     * @return
  +     *
  +     */
  +    public String getHugeString() {
  +        return mHugeStr;
       }
   }
  
  
  

--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>