< prev index next >

test/java/rmi/transport/checkLeaseInfoLeak/CheckLeaseLeak.java

Print this page


   1 /*
   2  * Copyright (c) 1998, 2013, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.
   8  *
   9  * This code is distributed in the hope that it will be useful, but WITHOUT
  10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  12  * version 2 for more details (a copy is included in the LICENSE file that
  13  * accompanied this code).
  14  *
  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  */
  23 
  24 /* @test
  25  * @bug 4116437
  26  * @summary Distributed Garbage Collector Memory Leak
  27  *
  28  * @author Laird Dornin
  29  *
  30  * @library ../../testlibrary
  31  * @modules java.rmi/sun.rmi.registry
  32  *          java.rmi/sun.rmi.server

  33  *          java.rmi/sun.rmi.transport
  34  *          java.rmi/sun.rmi.transport.tcp
  35  * @build TestLibrary CheckLeaseLeak_Stub LeaseLeakClient LeaseLeak
  36  * @run main/othervm/timeout=240 CheckLeaseLeak
  37  *
  38  */
  39 
  40 /**
  41  * A bug in sun.rmi.transport.DGCImp.checkLeases() results in memory
  42  * leak of LeaseInfo objects.
  43  *
  44  * In order to verify that this problem no longer exists, we create a
  45  * remote object and a serveral clients in different VMs. The clients
  46  * call a remote method on an exported object. This will cause the rmi
  47  * runtime to create several references (all with different vmids) to
  48  * the remote object.  Each vmid needs a seperate LeaseInfo object in
  49  * the object table target DGCImpl.leaseTable.  If the leak is fixed,
  50  * the leaseTable field will contain no objects.  We use reflection to
  51  * find the number of objects contained in this table.
  52  */


  73     private final static int ITERATIONS = 10;
  74     private final static int numberPingCalls = 0;
  75     private final static int CHECK_INTERVAL = 400;
  76     private final static int LEASE_VALUE = 20;
  77 
  78     public static void main (String[] args) {
  79         CheckLeaseLeak leakServer = null;
  80         int numLeft =0;
  81 
  82         /*
  83          * we want DGC to collect leases *quickly*
  84          * decrease the lease check interval
  85          */
  86         TestLibrary.setInteger("sun.rmi.dgc.checkInterval",
  87                                CHECK_INTERVAL);
  88         TestLibrary.setInteger("java.rmi.dgc.leaseValue",
  89                                LEASE_VALUE);
  90 
  91         try {
  92             Registry registry =
  93                 TestLibrary.createRegistryOnUnusedPort();
  94             int registryPort = TestLibrary.getRegistryPort(registry);
  95 
  96             leakServer = new CheckLeaseLeak();
  97             registry.rebind("/LeaseLeak", leakServer);
  98 
  99             /* create a bunch of clients in a *different* vm */
 100             for (int i = 0 ; i < ITERATIONS ; i ++ ) {
 101                 System.err.println("Created client: " + i);
 102 
 103                 JavaVM jvm = new JavaVM("LeaseLeakClient",
 104                                         " -Djava.security.policy=" +
 105                                         TestParams.defaultPolicy +
 106                                         " -Drmi.registry.port=" +
 107                                         registryPort,
 108                                         "");
 109 
 110                 if (jvm.execute() != 0) {
 111                     TestLibrary.bomb("Client process failed");
 112                 }
 113             }


   1 /*
   2  * Copyright (c) 1998, 2016, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.
   8  *
   9  * This code is distributed in the hope that it will be useful, but WITHOUT
  10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  12  * version 2 for more details (a copy is included in the LICENSE file that
  13  * accompanied this code).
  14  *
  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  */
  23 
  24 /* @test
  25  * @bug 4116437
  26  * @summary Distributed Garbage Collector Memory Leak
  27  *
  28  * @author Laird Dornin
  29  *
  30  * @library ../../testlibrary
  31  * @modules java.rmi/sun.rmi.registry
  32  *          java.rmi/sun.rmi.server
  33  *          java.rmi/sun.rmi.transport:open
  34  *          java.rmi/sun.rmi.transport
  35  *          java.rmi/sun.rmi.transport.tcp
  36  * @build TestLibrary CheckLeaseLeak_Stub LeaseLeakClient LeaseLeak
  37  * @run main/othervm/timeout=240 CheckLeaseLeak
  38  *
  39  */
  40 
  41 /**
  42  * A bug in sun.rmi.transport.DGCImp.checkLeases() results in memory
  43  * leak of LeaseInfo objects.
  44  *
  45  * In order to verify that this problem no longer exists, we create a
  46  * remote object and a serveral clients in different VMs. The clients
  47  * call a remote method on an exported object. This will cause the rmi
  48  * runtime to create several references (all with different vmids) to
  49  * the remote object.  Each vmid needs a seperate LeaseInfo object in
  50  * the object table target DGCImpl.leaseTable.  If the leak is fixed,
  51  * the leaseTable field will contain no objects.  We use reflection to
  52  * find the number of objects contained in this table.
  53  */


  74     private final static int ITERATIONS = 10;
  75     private final static int numberPingCalls = 0;
  76     private final static int CHECK_INTERVAL = 400;
  77     private final static int LEASE_VALUE = 20;
  78 
  79     public static void main (String[] args) {
  80         CheckLeaseLeak leakServer = null;
  81         int numLeft =0;
  82 
  83         /*
  84          * we want DGC to collect leases *quickly*
  85          * decrease the lease check interval
  86          */
  87         TestLibrary.setInteger("sun.rmi.dgc.checkInterval",
  88                                CHECK_INTERVAL);
  89         TestLibrary.setInteger("java.rmi.dgc.leaseValue",
  90                                LEASE_VALUE);
  91 
  92         try {
  93             Registry registry =
  94                 TestLibrary.createRegistryOnEphemeralPort();
  95             int registryPort = TestLibrary.getRegistryPort(registry);
  96 
  97             leakServer = new CheckLeaseLeak();
  98             registry.rebind("/LeaseLeak", leakServer);
  99 
 100             /* create a bunch of clients in a *different* vm */
 101             for (int i = 0 ; i < ITERATIONS ; i ++ ) {
 102                 System.err.println("Created client: " + i);
 103 
 104                 JavaVM jvm = new JavaVM("LeaseLeakClient",
 105                                         " -Djava.security.policy=" +
 106                                         TestParams.defaultPolicy +
 107                                         " -Drmi.registry.port=" +
 108                                         registryPort,
 109                                         "");
 110 
 111                 if (jvm.execute() != 0) {
 112                     TestLibrary.bomb("Client process failed");
 113                 }
 114             }


< prev index next >