-
Bug
-
Resolution: Cannot Reproduce
-
P1
-
None
-
1.1.6
-
x86
-
solaris_2.6
The following code shows the memory leak.
/**
* A simple test program that demonstrates that there are mmory leaks
* when creating new frames under JDK1.1.6
*
* We could watch the process size grows consistantly with the command:
*
* while true; do ps -orss,osz, -p thePid; sleep 2; done;
*
* finally the JVM will crash.
*
*/
import java.awt.*;
import java.awt.event.*;
public class FrameTest extends Frame implements Runnable, ActionListener{
Frame f;
int number = 0;
public static void main (String args[]){
FrameTest aTest = new FrameTest();
}
public FrameTest (){
Button b = new Button("test");
b.addActionListener(this);
this.add(b);
pack();
this.setVisible(true);
}
public synchronized void actionPerformed( ActionEvent e ) {
Thread aThread = new Thread(this);
aThread.start();
}
public void run()
{
for (int i = 0; i < 50000; i++) {
number = number + 1;
System.out.println("number= " + number);
f = new Frame();
f.setSize(300,100);
f.setVisible(true);
try{
Thread.currentThread().sleep(25);
}catch(InterruptedException e){;}
f.setVisible(false);
f.dispose();
f=null;
}
}
}
/**
* A simple test program that demonstrates that there are mmory leaks
* when creating new frames under JDK1.1.6
*
* We could watch the process size grows consistantly with the command:
*
* while true; do ps -orss,osz, -p thePid; sleep 2; done;
*
* finally the JVM will crash.
*
*/
import java.awt.*;
import java.awt.event.*;
public class FrameTest extends Frame implements Runnable, ActionListener{
Frame f;
int number = 0;
public static void main (String args[]){
FrameTest aTest = new FrameTest();
}
public FrameTest (){
Button b = new Button("test");
b.addActionListener(this);
this.add(b);
pack();
this.setVisible(true);
}
public synchronized void actionPerformed( ActionEvent e ) {
Thread aThread = new Thread(this);
aThread.start();
}
public void run()
{
for (int i = 0; i < 50000; i++) {
number = number + 1;
System.out.println("number= " + number);
f = new Frame();
f.setSize(300,100);
f.setVisible(true);
try{
Thread.currentThread().sleep(25);
}catch(InterruptedException e){;}
f.setVisible(false);
f.dispose();
f=null;
}
}
}