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 14:32:40 UTC

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

hammant     02/03/27 05:32:40

  Added:       altrmi/src/java/org/apache/commons/altrmi/test
                        MemoryLeak.java MemoryLeakClientTest.java
                        MemoryLeakImpl.java MemoryLeakServerTest.java
  Log:
  memory leak tests.
  
  Revision  Changes    Path
  1.1                  jakarta-commons-sandbox/altrmi/src/java/org/apache/commons/altrmi/test/MemoryLeak.java
  
  Index: MemoryLeak.java
  ===================================================================
  /*
   * Copyright (C) The Apache Software Foundation. All rights reserved.
   *
   * This software is published under the terms of the Apache Software License
   * version 1.1, a copy of which has been included with this distribution in
   * the LICENSE.txt file.
   */
  package org.apache.commons.altrmi.test;
  
  public interface MemoryLeak {
  
      MemoryLeak getNewMemoryLeak();
  }
  
  
  
  1.1                  jakarta-commons-sandbox/altrmi/src/java/org/apache/commons/altrmi/test/MemoryLeakClientTest.java
  
  Index: MemoryLeakClientTest.java
  ===================================================================
  
  /*
   * Copyright (C) The Apache Software Foundation. All rights reserved.
   *
   * This software is published under the terms of the Apache Software License
   * version 1.1, a copy of which has been included with this distribution in
   * the LICENSE.txt file.
   */
  package org.apache.commons.altrmi.test;
  
  
  
  import org.apache.commons.altrmi.client.AltrmiHostContext;
  import org.apache.commons.altrmi.client.AltrmiFactory;
  import org.apache.commons.altrmi.common.AltrmiConnectionException;
  import org.apache.commons.altrmi.client.impl.socket.SocketObjectStreamHostContext;
  import org.apache.commons.altrmi.client.impl.socket.SocketCustomStreamHostContext;
  import org.apache.commons.altrmi.client.impl.ServerClassAltrmiFactory;
  import org.apache.commons.altrmi.client.impl.ClientClassAltrmiFactory;
  
  import java.io.IOException;
  
  
  /**
   * Class MemoryLeakClientTest
   *
   *
   * @author Paul Hammant <a href="mailto:Paul_Hammant@yahoo.com">Paul_Hammant@yahoo.com</a>
   * @version $Revision: 1.1 $
   */
  public class MemoryLeakClientTest {
  
      /**
       * Constructor MemoryLeakClientTest
       *
       *
       * @param ml
       *
       */
      public MemoryLeakClientTest(MemoryLeak ml) {
  
          long start = System.currentTimeMillis();
  
          for (int i = 0; i < 100000000; i++) {
              MemoryLeak tmpMl = ml.getNewMemoryLeak();
  
              System.gc(); // pointless ?
              if (("" + i).endsWith("000")) {
                  long end = System.currentTimeMillis();
                  System.out.println("Iter "
                          + i + ", "
                          + (end-start) / 1000
                          + " seconds, Tot Mem :"
                          + Runtime.getRuntime().totalMemory()
                          + ", Max Mem :"
                          + Runtime.getRuntime().maxMemory()
                          + ", Free Mem :"
                          + Runtime.getRuntime().freeMemory()
                  );
                  end = start;
              }
          }
      }
  
      /**
       * Method main
       *
       *
       * @param args
       *
       * @throws Exception
       *
       */
      public static void main(String[] args) throws Exception {
  
          System.out.println("Memory Leak Client");
  
          AltrmiFactory af = new ClientClassAltrmiFactory(false);
  
          af.setHostContext(new SocketCustomStreamHostContext("127.0.0.1", 1277));
  
          MemoryLeak ml = (MemoryLeak) af.lookup("MemLeak");
  
          new MemoryLeakClientTest(ml);
          af.close();
      }
  }
  
  
  
  1.1                  jakarta-commons-sandbox/altrmi/src/java/org/apache/commons/altrmi/test/MemoryLeakImpl.java
  
  Index: MemoryLeakImpl.java
  ===================================================================
  /*
   * Copyright (C) The Apache Software Foundation. All rights reserved.
   *
   * This software is published under the terms of the Apache Software License
   * version 1.1, a copy of which has been included with this distribution in
   * the LICENSE.txt file.
   */
  package org.apache.commons.altrmi.test;
  
  public class MemoryLeakImpl implements MemoryLeak {
  
      public MemoryLeak getNewMemoryLeak() {
          System.gc(); // pointless ?
          return new MemoryLeakImpl();
      }
  }
  
  
  
  1.1                  jakarta-commons-sandbox/altrmi/src/java/org/apache/commons/altrmi/test/MemoryLeakServerTest.java
  
  Index: MemoryLeakServerTest.java
  ===================================================================
  
  /*
   * Copyright (C) The Apache Software Foundation. All rights reserved.
   *
   * This software is published under the terms of the Apache Software License
   * version 1.1, a copy of which has been included with this distribution in
   * the LICENSE.txt file.
   */
  package org.apache.commons.altrmi.test;
  
  import org.apache.commons.altrmi.server.impl.socket.CompleteSocketCustomStreamServer;
  import org.apache.commons.altrmi.server.impl.AbstractServer;
  import org.apache.commons.altrmi.server.PublicationDescription;
  
  import java.io.IOException;
  
  
  /**
   * Class MemoryLeakServerTest
   *
   *
   * @author Paul Hammant <a href="mailto:Paul_Hammant@yahoo.com">Paul_Hammant@yahoo.com</a>
   * @version $Revision: 1.1 $
   */
  public class MemoryLeakServerTest {
  
      /**
       * Method main
       *
       *
       * @param args
       *
       * @throws Exception
       *
       */
      public static void main(String[] args) throws Exception {
  
          System.out.println("MemoryLeak Server");
          AbstractServer as = new CompleteSocketCustomStreamServer(1277);
          MemoryLeakImpl ml = new MemoryLeakImpl();
          as.publish(ml, "MemLeak", new PublicationDescription(MemoryLeak.class, MemoryLeak.class));
          as.start();
      }
  }
  
  
  

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