Java Solaris Communities Sun Store Join SDN My Profile Why Join?
 
Bug Database
Bug Detail
Quick Lists
Top 25 Bugs
Top 25 RFE's
Recently Closed Bugs
Printable Page Printable Page


Bug Database
Bug ID: 6692197
Votes 0
Synopsis OutofMemory observed while loading large files into JTextArea
Category java:classes_swing
Reported Against
Release Fixed
State 1-Dispatched, bug
Priority: 3-Medium
Related Bugs 5089193 , 4203912
Submit Date 22-APR-2008
Description
OPERATING SYSTEM(S):
Windows XP

FULL JDK VERSION(S):
java version "1.6.0_05"
Java(TM) SE Runtime Environment (build 1.6.0_05-b13)
Java HotSpot(TM) Client VM (build 10.0-b19, mixed mode)

TESTCASE DESCRIPTION:

1. The application (testcase) creates a GUI with buttons to load a file
   into JTextArea or to run GC.
2. If the button to load the file is clicked, then a thread is spawned
   which creates a new JFrame Window with a JTextArea component, where
   the file can be loaded.
3. Once the file contents are loaded into the file, the JTextArea
   Window can be closed.

RECREATION INSTRUCTIONS:

  To recreate, compile MyThread.java and JTextAreaTest.java (see attachemtns)
and then run the testcase as follows:

   java JTextAreaTest

1. Launch the application, select the option to load a file.
2. Load a huge file of size (80MB-120MB) into JTextArea. Once the file
   contents are observed, close the window.
3. Repeat step 2 five or six times on a machine with 1G RAM and we
   should be able to observe the OutofMemory Error with the following
   stack trace:

java.lang.OutOfMemoryError:
at javax.swing.text.GapContent.allocateArray(GapContent.java:106)
at javax.swing.text.GapVector.resize(GapVector.java:226)
at javax.swing.text.GapVector.shiftEnd(GapVector.java:241)
at javax.swing.text.GapContent.shiftEnd(GapContent.java:355)
at javax.swing.text.GapVector.open(GapVector.java(Compiled Code))
at javax.swing.text.GapVector.replace(GapVector.java(Compiled Code))
at javax.swing.text.GapContent.insertString(GapContent.java(Inlined Compiled Code))
at javax.swing.text.AbstractDocument.handleInsertString(AbstractDocument.java(Compiled Code))
at javax.swing.text.AbstractDocument.insertString(AbstractDocument.java(Compiled Code))
at javax.swing.text.PlainDocument.insertString(PlainDocument.java(Compiled Code))
at javax.swing.text.DefaultEditorKit.read(DefaultEditorKit.java(Compiled Code))
at javax.swing.text.JTextComponent.read(JTextComponent.java:1350)
at MyThread.readin(MyThread.java:81)
at MyThread.run(MyThread.java:115)

The testcase listens for WindowClosing event.  When the window is closed, the instance of JTextArea, JFrame and all the panels are nullified.  This should cause the old instances of JTextArea and array that is used to store the data, which is internally created in GapContent class should get cleared and the memory occupied by the array should be released back.  However, this does not seem to be happening, which causes the memory to be accumulated and eventually leading to OOM.
Posted Date : 2008-04-22 18:31:02.0
Work Around
N/A
Evaluation
N/A
Comments
  
  Include a link with my name & email   


PLEASE NOTE: JDK6 is formerly known as Project Mustang