-
Bug
-
Resolution: Fixed
-
P3
-
6
-
b17
-
x86
-
windows_98, windows_2000
-
Not verified
Issue | Fix Version | Assignee | Priority | Status | Resolution | Resolved In Build |
---|---|---|---|---|---|---|
JDK-2202723 | 6-pool | Mikhail Cherkasov | P3 | Closed | Cannot Reproduce |
FULL PRODUCT VERSION :
C:\temp\bug>java -version
java version "1.4.1-beta"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.1-beta-b14)
Java HotSpot(TM) Client VM (build 1.4.1-beta-b14, mixed mode)
FULL OPERATING SYSTEM VERSION :
Microsoft Windows 2000 [Version 5.00.2195]
A DESCRIPTION OF THE PROBLEM :
Attached is sample code that causes a memory leak under 1.3 and 1.4.1. This sample adds one line of code to the already closed bug 4495338.
This bug is causing us to have a major memory leak in our application.
This bug also causes Frames and Dialogs to keep the JVM from exiting once all the frames are closed and disposed.
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
1. javac TestCase.java
2. java TestCase
EXPECTED VERSUS ACTUAL BEHAVIOR :
Expected:
Dialog1 being finalized
Dialog2 being finalized
Dialog3 being finalized
Got:
Dialog1 being finalized
Dialog2 being finalized
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
import javax.swing.*;
class TestDialog extends JDialog {
String name;
public TestDialog(String name) {
this.name = name;
}
public void show() {
super.show();
dispose(); // so no user interaction is needed
}
public void finalize() {
System.out.println(name + " being finalized");
}
}
public class TestCase {
public static void main(String[] arg) {
TestDialog dialog1 = new TestDialog("Dialog1");
TestDialog dialog2 = new TestDialog("Dialog2");
TestDialog dialog3 = new TestDialog("Dialog3");
// do nothing to Dialog1
// pack Dialog2
dialog2.pack(); //this is empty size 0,0
dialog2.dispose();
// show Dialog3
dialog3.setSize(200,200); //added this line
dialog3.show();
// should be garbage collectable after this
dialog1 = null;
dialog2 = null;
dialog3 = null;
for (int i = 0; i < 20; i++)
System.gc();
System.exit(0);
}
}
---------- END SOURCE ----------
CUSTOMER WORKAROUND :
Use no more than one JFrame or JDialog in your application.
(Review ID: 160375)
======================================================================
- backported by
-
JDK-2202723 Dialogs and Frames are never garbage collected
-
- Closed
-
- duplicates
-
JDK-4850815 Swing does not stop painter thread
-
- Closed
-
- relates to
-
JDK-4859570 SwingUtilities.sharedOwnerFrame is never disposed
-
- Resolved
-
-
JDK-4895582 Infinite count of WINDOW_CLOSED events when dispose window owner
-
- Closed
-
-
JDK-6573198 PIT: NullPointerException when trying print-to-file from a native print dialog, Win32
-
- Closed
-
-
JDK-6217590 Autotransfer moves focus to removed component
-
- Closed
-
-
JDK-6515061 Incorrect focus owner when hiding the components
-
- Closed
-
-
JDK-6607170 Focus not set by requestFocus
-
- Closed
-
-
JDK-6233069 JOptionPane.createDialog leaks resources
-
- Closed
-
-
JDK-6321947 GC does not complete after Frame.dispose() until focus/unfocus of another Frame
-
- Closed
-
-
JDK-6511554 one more problem with focus auto transfer
-
- Closed
-
-
JDK-6566905 getFocusOwner() return Invisible component as focusowner
-
- Closed
-