Name: nt126004 Date: 10/03/2001
java version "1.3.1_01"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.3.1_01)
Java HotSpot(TM) Client VM (build 1.3.1_01, mixed mode)
There is a huge memory leak when writing to the console.
The problem only exists when the application is started through
Java Web Start.
Programs which are started through "Java Web Start" are very
difficult to debug.
I was having a problem which resulted in Threads being killed.
One of the Threads was the Event-Dispatch-Thread.
After many hours I discovered that the real problem was
an "Out of Memory" exception.
I profiled the application with OptimizeIt and discovered that
a few classes were not garbage collected.
Among these classes were :
javax.swing.text.GapContent$MarkData
javax.swing.text.GapContent$StickyPosition
javax.swing.text.AbstractDocument$LeafElement.
These classes were instantiated in the class :
com.sun.javaws.ui.console.Console
After I examined the profile a little bit better I found
that each time I used the method "System.out.println" memory
was leaked.
I have no workaround for this problem. (Except that I don't use
Java Web Start now anymore)
The problem can be demonstrated with the program :
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
public class Test
{
public Test()
{
JFrame frame = new JFrame("Test");
JButton exit = new JButton("Exit Program");
exit.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent ae)
{
System.exit(0);
}
});
frame.getContentPane().add(exit, BorderLayout.CENTER);
frame.pack();
frame.show();
doTest();
}
private void doTest()
{
try
{
for (; ; )
{
System.out
.println("Test 0123456789 Test 0123456789 Test 0123456789 Test 0123456
789 Test 0123456789 Test 0123456789 Test 0123456789");
Thread.currentThread().sleep(100);
}
}
catch (Exception ex)
{
ex.printStackTrace();
}
}
static public void main(String args[])
{
new Test();
}
}
(Review ID: 133010)
======================================================================