<Swing Dev> Is the following code supposed to leak?
Clemens Eisserer
linuxhippy at gmail.com
Sat Aug 20 09:54:53 UTC 2011
Hi Roman,
You keep creating and adding new listeners without ever removing them.
> Of course this is going to leak.
What makes me wonder, I add the listeners to an Action from a newly created
JTextArea.
Shouldn't the action belong to the JTextArea itself and be garbage-collected
too when the JTextArea is no longer reachable? (like its the case for
Listeners attached to the Component directly like Mouse/Key/...-Listeners)
In the case of Notepad, that would mean Swing would require the application
to remove the listeners manually?
I have to admit I don't understand the concept of Actions in detail...
> It's not even related to the fact that
> the listener references the array (although that could play a role in
> more complicated leaking scenarios)
>
Sure, the array is just there to trigger the OOM faster ;).
Thanks, Clemens
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.openjdk.java.net/pipermail/swing-dev/attachments/20110820/b6f7475a/attachment.html>
More information about the swing-dev
mailing list