equal
deleted
inserted
replaced
1 /* |
1 /* |
2 * Copyright (c) 2016, 2017, Oracle and/or its affiliates. All rights reserved. |
2 * Copyright (c) 2016, 2018, Oracle and/or its affiliates. All rights reserved. |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 * |
4 * |
5 * This code is free software; you can redistribute it and/or modify it |
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 |
6 * under the terms of the GNU General Public License version 2 only, as |
7 * published by the Free Software Foundation. |
7 * published by the Free Software Foundation. |
22 */ |
22 */ |
23 |
23 |
24 /** |
24 /** |
25 * @test |
25 * @test |
26 * @key headful |
26 * @key headful |
27 * @bug 8158325 8180821 |
27 * @bug 8158325 8180821 8202878 |
28 * @summary Memory leak in com.apple.laf.ScreenMenu: removed JMenuItems are still referenced |
28 * @summary Memory leak in com.apple.laf.ScreenMenu: removed JMenuItems are still referenced |
29 * @requires (os.family == "mac") |
29 * @requires (os.family == "mac") |
|
30 * @library /javax/swing/regtesthelpers |
|
31 * @build Util |
30 * @run main/timeout=300/othervm -Xmx16m ScreenMenuMemoryLeakTest |
32 * @run main/timeout=300/othervm -Xmx16m ScreenMenuMemoryLeakTest |
31 */ |
33 */ |
32 |
34 |
33 import java.awt.EventQueue; |
35 import java.awt.EventQueue; |
34 import java.lang.ref.WeakReference; |
36 import java.lang.ref.WeakReference; |
41 import javax.swing.JMenuBar; |
43 import javax.swing.JMenuBar; |
42 import javax.swing.JMenuItem; |
44 import javax.swing.JMenuItem; |
43 import javax.swing.WindowConstants; |
45 import javax.swing.WindowConstants; |
44 |
46 |
45 public class ScreenMenuMemoryLeakTest { |
47 public class ScreenMenuMemoryLeakTest { |
46 |
|
47 private static byte[] sBytes; |
|
48 |
48 |
49 private static WeakReference<JMenuItem> sMenuItem; |
49 private static WeakReference<JMenuItem> sMenuItem; |
50 private static JFrame sFrame; |
50 private static JFrame sFrame; |
51 private static JMenu sMenu; |
51 private static JMenu sMenu; |
52 |
52 |
63 @Override |
63 @Override |
64 public void run() { |
64 public void run() { |
65 removeMenuItemFromMenu(); |
65 removeMenuItemFromMenu(); |
66 } |
66 } |
67 }); |
67 }); |
68 System.gc(); |
68 |
69 System.runFinalization(); |
69 Util.generateOOME(); |
70 Thread.sleep(1000); |
|
71 JMenuItem menuItem = sMenuItem.get(); |
70 JMenuItem menuItem = sMenuItem.get(); |
72 EventQueue.invokeAndWait(new Runnable() { |
71 EventQueue.invokeAndWait(new Runnable() { |
73 @Override |
72 @Override |
74 public void run() { |
73 public void run() { |
75 sFrame.dispose(); |
74 sFrame.dispose(); |