-
Bug
-
Resolution: Not an Issue
-
P4
-
None
-
1.3.0, 1.3.1
-
x86
-
windows_nt, windows_2000
Name: yyT116575 Date: 02/06/2001
java version "1.3.0"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.3.0-C)
Java HotSpot(TM) Client VM (build 1.3.0-C, mixed mode)
/*
* FrameMemoryLeak.java
*
* Philip Koester
* ###@###.###
*
* This very simple program does nothing more than simply show a frame.
* However, when launched, the corresponding java.exe process occupies
* no less than 8 MB physical RAM on my W2K system.
*
* As it turns out, manually minimizing and restoring the frame results
* in only 2 MB constant heap usage. The java process will then never peak up
* to 8 MB again (not even to 3). So I suspect a significant memory leak here.
* (Sorry, have no other platforms handy I could test this on.)
*
* Doing the minimize/restore trick in Java code has a similar effect,
* although it seems that it saves a little less memory. (Set the trick
* boolean to true in the code below to test this.)
*
* In real-life Java applications, the difference can be as much as
* 30 MB. This is how I noticed the problem ...
*/
import java.awt.*;
import java.awt.event.*;
public class FrameMemoryLeak {
public static void main(String[] args) {
// create a frame (no children, no nothing)
Frame f = new Frame("Frame Memory Leak");
f.setBounds(200, 200, 400, 400);
// make it closable
f.addWindowListener(new WindowAdapter() {
public void windowClosing(WindowEvent e) {
System.exit(0);
}
});
// show the frame
f.setVisible(true);
// if trick is true, this program temporarily minimizes the
// frame and then directly restores it again. makes a huge difference
// with respect to memory consumption!
boolean trick = false;
if (trick) {
// perform the trick
f.setState(f.ICONIFIED);
f.setState(f.NORMAL);
f.requestFocus();
}
}
}
// EOF
(Review ID: 116390)
======================================================================
Name: yyT116575 Date: 08/23/2001
F:\jdk1.3.1\bin>java -version
java version "1.3.1"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.3.1-b24)
Java HotSpot(TM) Client VM (build 1.3.1-b24, mixed mode)
1. Make a frame and some garbage and minimize the frame by hand.
Windows NT is freezed for a longer time and the frame (or the remainders) is
glued to the desktop. I think it is normal behaviour for Windows, but with java
it is very extreme. Probable it is coupled with BUG 4412569.
2. the source code from BUG 4412569 added with garbage.
When iconifying the frame, it freezes the system. When maximizing/deiconifying
it, the "normal" memory is freed, but the virtual memory is constant (task
manager). I think the heap goes never back to the operation system, but some
kind of cleaning freezes the system.
/*
* FrameMemoryLeak.java
*
* Philip Koester
* xxxxx@xxxxx
*
* This very simple program does nothing more than simply show a frame.
* However, when launched, the corresponding java.exe process occupies
* no less than 8 MB physical RAM on my W2K system.
*
* As it turns out, manually minimizing and restoring the frame results
* in only 2 MB constant heap usage. The java process will then never peak up
* to 8 MB again (not even to 3). So I suspect a significant memory leak here.
* (Sorry, have no other platforms handy I could test this on.)
*
* Doing the minimize/restore trick in Java code has a similar effect,
* although it seems that it saves a little less memory. (Set the trick
* boolean to true in the code below to test this.)
*
* In real-life Java applications, the difference can be as much as
* 30 MB. This is how I noticed the problem ...
*/
import java.awt.*;
import java.awt.event.*;
public class FrameMemoryLeak {
static int[] t=new int[10000000]; // produce garbage
public static void main(String[] args) {
// create a frame (no children, no nothing)
Frame f = new Frame("Frame Memory Leak");
f.setBounds(200, 200, 400, 400);
// make it closable
f.addWindowListener(new WindowAdapter() {
public void windowClosing(WindowEvent e) {
System.exit(0);
}
});
t=null;// produce garbage
// show the frame
f.setVisible(true);
// if trick is true, this program temporarily minimizes the
// frame and then directly restores it again. makes a huge difference
// with respect to memory consumption!
boolean trick = false;
if (trick) {
// perform the trick
f.setState(f.ICONIFIED);
f.setState(f.NORMAL);
f.requestFocus();
}
}
}
(Review ID: 130544)
======================================================================
- relates to
-
JDK-4331383 Memory leaks until frame minimized
- Closed
-
JDK-6193438 Implement workaround for bug #4412569 to safely reduce the "working set"
- Open