United StatesChange Country, Oracle Worldwide Web Sites Communities I am a... I want to...
JDK-4510364 : Memoryleak in Java Web Start

Details
Type:
Bug
Submit Date:
2001-10-03
Status:
Resolved
Updated Date:
2002-03-08
Project Name:
JDK
Resolved Date:
2001-11-20
Component:
deploy
OS:
windows_nt
Sub-Component:
webstart
CPU:
x86
Priority:
P2
Resolution:
Fixed
Affected Versions:
1.0.1
Fixed Versions:
1.2.0 (1.2)

Related Reports
Backport:

Sub Tasks

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
PUBLIC COMMENTS

Fixed in Java Web Start 1.2.

Added a new property javaws.cfg.consoleBufferSize with default value of 10000.
                                     
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
EVALUATION

Fixed and tested.
                                     
2004-08-31
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



Hardware and Software, Engineered to Work Together