Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 357072 - AbstractChannel.listeners_array leaks listener instances
Summary: AbstractChannel.listeners_array leaks listener instances
Status: RESOLVED FIXED
Alias: None
Product: TCF
Classification: Tools
Component: Core (show other bugs)
Version: 1.0   Edit
Hardware: All All
: P3 normal (vote)
Target Milestone: 1.0.0   Edit
Assignee: Project Inbox CLA
QA Contact: Eugene Tarassov CLA
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-09-08 08:31 EDT by Anton Leherbauer CLA
Modified: 2011-10-04 11:59 EDT (History)
2 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Anton Leherbauer CLA 2011-09-08 08:31:04 EDT
The static field AbstractChannel.listeners_array is used only temporarily for notifying IChannelListeners, but this keeps those listeners from being GC'ed (until the next channel event is fired).  As listeners are often anonymous inner classes this can lead to quite serious memory leaks.
I'd suggest to clear the array after notifying the listeners.
Comment 1 Eugene Tarassov CLA 2011-09-08 14:14:06 EDT
I have both removed "static" and changed the code to clear the array when the channel is closed or a listener is removed.
Comment 2 Anton Leherbauer CLA 2011-09-09 08:05:44 EDT
There is one problem, though: If a listener removes itself when it receives onChannelClosed(), all subsequent listeners will not receive the notification because the listeners_array is cleared.
Comment 3 Eugene Tarassov CLA 2011-09-09 12:09:47 EDT
Good catch.
Looks like the original idea of reusing the array was wrong - it does not worth all the trouble. I have removed listeners_array and changed the code to create temporary array each time listeners are called.
Thanks!
Comment 4 Martin Oberhuber CLA 2011-10-04 04:57:57 EDT
It looks like this was committed to master only, but not to 0.5.0 - is this intentional?

http://git.eclipse.org/c/tcf/org.eclipse.tcf.git/commit/?id=da88b9a9263f5a97b98112dd7a600ffaf331a181
Comment 5 Eugene Tarassov CLA 2011-10-04 11:59:28 EDT
(In reply to comment #4)
> It looks like this was committed to master only, but not to 0.5.0 - is this
> intentional?

The issue looks noncritical to me, but the fix can easily be backported to 0.5.0 if anyone needs it.