<Swing Dev> [10] RFR JDK-8175968: The javax.swing.filechooser.FileSystemView constructor consumes memory by adding a PropertyChangeListener that is never removed.

Robin Stevens stevensro at gmail.com
Tue Jul 4 09:54:03 UTC 2017


- There should be no need to create a public dispose method and shift the
responsibility of disposing the listener to the user of the FileSystemView
class.

You can simply convert the PropertyChangeListener to a so-called weak
listener, and keep this PropertyChangeListener an implementation detail
(see the WeakChangeListener in javafx.beans.value package for an example of
what I mean with a weak listener, or
http://www.jroller.com/santhosh/entry/use_weak_listeners_to_avoid).

- The javadoc of that new dispose method is unclear. How do you suppose
somebody somebody will know what "the PropertyChangeListener" is. This
remark of course becomes irrelevant if you remove that method from the
public API.

Robin

On Tue, Jul 4, 2017 at 11:40 AM, Prasanta Sadhukhan <
prasanta.sadhukhan at oracle.com> wrote:

> Hi All,
>
> Please review a fix for a memory leak issue where PropertyChangeListener
> object added by FileSystemView constructor is never removed.
> Proposed fix is to add dispose() method to be called by app when they want
> to remove this resource.
>
> Bug: https://bugs.openjdk.java.net/browse/JDK-8175968
> webrev: http://cr.openjdk.java.net/~psadhukhan/8175968/webrev.00/
>
> Regards
> Prasanta
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.openjdk.java.net/pipermail/swing-dev/attachments/20170704/63670992/attachment.html>


More information about the swing-dev mailing list