JDK-4510364 : Memoryleak in Java Web Start
  • Type: Bug
  • Component: deploy
  • Sub-Component: webstart
  • Affected Version: 1.0.1
  • Priority: P2
  • Status: Resolved
  • Resolution: Fixed
  • OS: windows_nt
  • CPU: x86
  • Submitted: 2001-10-03
  • Updated: 2002-03-08
  • Resolved: 2001-11-20
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availabitlity Release.

To download the current JDK release, click here.
Other
1.2.0 1.2Fixed
Description

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) 
======================================================================

Comments
CONVERTED DATA BugTraq+ Release Management Values COMMIT TO FIX: 1.2 hopper FIXED IN: 1.2 hopper INTEGRATED IN: 1.2 hopper
2004-08-31

EVALUATION Fixed and tested.
2004-08-31

SUGGESTED FIX There is no Memoryleak. It is Memory buildup which is due to infinitely growing Document object inside the Console.I added a new Config property to control the size of Console. Default value is 10,000 characters. ConfigProperties.java : Added a new property javaws.cfg.consoleBufferSize with default value of 10000. Console.java : // If the User has n't specified config property to control the // size of Console Buffer, then restrict the size of Console to // default value (10000). If config property (consoleBufferSize) // is specified, then use that specific value. // Remove that many characters in the top so that console will // hold only fixed number of chars and will not grow infinitely. // This is to prevent any memory buildup. // If the value of the config property specified is 0, // then we will not delete any stuff and allow it to grow. if ((length > _consoleSize) && (_consoleSize > 0)) { _document.remove(0,length - _consoleSize); length = _consoleSize; }
2004-08-31

PUBLIC COMMENTS Fixed in Java Web Start 1.2. Added a new property javaws.cfg.consoleBufferSize with default value of 10000.
2004-08-31