test/jdk/com/apple/laf/ScreenMenu/ScreenMenuMemoryLeakTest.java
changeset 50144 2a85d59e7f8b
parent 47387 4d711a58bb3b
--- a/test/jdk/com/apple/laf/ScreenMenu/ScreenMenuMemoryLeakTest.java	Fri May 11 14:12:55 2018 -0700
+++ b/test/jdk/com/apple/laf/ScreenMenu/ScreenMenuMemoryLeakTest.java	Fri May 11 15:27:51 2018 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2016, 2017, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2016, 2018, 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
@@ -24,9 +24,11 @@
 /**
  * @test
  * @key headful
- * @bug 8158325 8180821
+ * @bug 8158325 8180821 8202878
  * @summary Memory leak in com.apple.laf.ScreenMenu: removed JMenuItems are still referenced
  * @requires (os.family == "mac")
+ * @library /javax/swing/regtesthelpers
+ * @build Util
  * @run main/timeout=300/othervm -Xmx16m ScreenMenuMemoryLeakTest
  */
 
@@ -44,8 +46,6 @@
 
 public class ScreenMenuMemoryLeakTest {
 
-    private static byte[] sBytes;
-
     private static WeakReference<JMenuItem> sMenuItem;
     private static JFrame sFrame;
     private static JMenu sMenu;
@@ -65,9 +65,8 @@
                 removeMenuItemFromMenu();
             }
         });
-        System.gc();
-        System.runFinalization();
-        Thread.sleep(1000);
+
+        Util.generateOOME();
         JMenuItem menuItem = sMenuItem.get();
         EventQueue.invokeAndWait(new Runnable() {
             @Override