United StatesChange Country, Oracle Worldwide Web Sites Communities I am a... I want to...
Bug ID: JDK-6520101 FileChooser will cause OutOfMemory when application will run long time
JDK-6520101 : FileChooser will cause OutOfMemory when application will run long time

Details
Type:
Bug
Submit Date:
2007-02-01
Status:
Resolved
Updated Date:
2011-03-01
Project Name:
JDK
Resolved Date:
2008-04-03
Component:
client-libs
OS:
windows_xp
Sub-Component:
javax.swing
CPU:
x86
Priority:
P3
Resolution:
Fixed
Affected Versions:
1.4.2_13
Fixed Versions:
1.4.2_18 (b05)

Related Reports
Backport:
Backport:
Backport:
Backport:
Relates:
Relates:

Sub Tasks

Description
FileChooseDemo will cause OutOfMemory in long run

CONFIGURATION :
 JRE :1.4.2_13
 OS : WindowsXP(SP2, japanese)

REPRODUCE :
1) Invoke the following command
   java -showversion -Xmx8m -verbose:gc -jar FileChooserDemo.jar
2) Click "ShowFileChooser"
3) click "cancel" in file chooser dialogue.
4) click "O.K" on message dialogue
5) select L&F type by clicking "metal", "motif" or "Windows" radio button.
   Repeat the step 5)

NOTE : 
  The heap size is very small, 8m. This is set just to reproduce quickly.
  Real application of customer has bigger heap size. So, it takes long time to reproduce.

                                    

Comments
EVALUATION

I have tried to evaluate this issue and found that this happens with Motif LNF. I have tested with Metal and Windows LNF and it the testacase doesn't throw OOM with Metal and Windows LNF. This happens only with Motif LNF. I am attaching (bug6520101.java) a more simple testcase to reproduce this issue. Please follow these steps to reproduce this issue.

I have tried to debug the issue and found that MotifFileChooserUI is leaking memory. 
The heap histogram clearly shows that MotifFileChooserUI is leaking memory.
                                     
2007-03-27
SUGGESTED FIX

The fix require changes in 2 functions
1.)  public void uninstallComponents(JFileChooser fc) {
    fc.removeAll();
    + directoryPanel = null; (added this line)
    }

2.) public void uninstallUI(JComponent c) {
       + c.removePropertyChangeListener(filterComboBoxModel); (added this line)
       + approveButton.removeActionListener(getApproveSelectionAction()); (added this line)
       + filenameTextField.removeActionListener(getApproveSelectionAction()); (added this line)
       super.uninstallUI(c);
    }
                                     
2007-03-27
EVALUATION

Fixed via 1.4.2_17-rev-b10.
                                     
2008-04-03



Hardware and Software, Engineered to Work Together