JDK-6520101 : FileChooser will cause OutOfMemory when application will run long time
  • Type: Bug
  • Component: client-libs
  • Sub-Component: javax.swing
  • Affected Version: 1.4.2_13
  • Priority: P3
  • Status: Resolved
  • Resolution: Fixed
  • OS: windows_xp
  • CPU: x86
  • Submitted: 2007-02-01
  • Updated: 2011-03-01
  • Resolved: 2008-04-03
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 Availability Release.

To download the current JDK release, click here.
Other JDK 6 JDK 7
1.4.2_17-revFixed 6u4Fixed 7Fixed
Related Reports
Relates :  
Relates :  
FileChooseDemo will cause OutOfMemory in long run

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

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)

  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.

EVALUATION Fixed via 1.4.2_17-rev-b10.

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); }

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.