< prev index next >

test/jdk/java/rmi/server/UnicastRemoteObject/unexportObject/UnexportLeak.java

Print this page
rev 54612 : Checkpoint latest preliminary review patches for full OpenJDK review; merge with 8222295.patch.

@@ -1,7 +1,7 @@
 /*
- * Copyright (c) 2000, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2000, 2019, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
  * under the terms of the GNU General Public License version 2 only, as
  * published by the Free Software Foundation.

@@ -72,19 +72,22 @@
             throw new RuntimeException("FAILED: RemoteException encountered");
         }
     }
 
     /**
-     * Force desparate garbage collection so that all WeakReference instances
+     * Force desperate garbage collection so that all WeakReference instances
      * will be cleared.
      */
     private static void flushRefs() {
         java.util.Vector chain = new java.util.Vector();
         try {
             while (true) {
                 int[] hungry = new int[65536];
                 chain.addElement(hungry);
             }
         } catch (OutOfMemoryError e) {
+            // An inflated Java monitor can keep 'obj' alive so request
+            // an explicit GC to make sure things are cleaned up.
+            System.gc();
         }
     }
 }
< prev index next >