History | Log In     View a printable version of the current page.  
Issue Details (XML)

Key: SDK-16161
Type: Bug Bug
Status: Closed Closed
Resolution: Not a Bug
Priority: None None
Assignee: Ella Mitelman
Reporter: Tink
Votes: 0
Watchers: 1
Operations

If you were logged in you would be able to see more operations.
Flex SDK

Not removing listeners from thumbs on a slider

Created: 07/22/08 05:46 AM   Updated: 09/06/08 12:48 PM
Component/s: mx: Slider
Security Level: Public (All JIRA Users )

Severity: Memory Leak
Reproducibility: Every Time
Discoverability: Medium
Found in Version: SDK Flex 3 (Released)
Affected OS(s): All OS Platforms - All
Steps to Reproduce:
The create thumbs method destroys all current thumbs and the creates new ones (Slider line 1715).

When it destroys the thumbs it doesn't remove the listeners added when they are created...

thumb.addEventListener(FocusEvent.FOCUS_IN,
thumb_focusInHandler);
thumb.addEventListener(FocusEvent.FOCUS_OUT,
thumb_focusOutHandler);

and these do not use a weakReference.

It would also be more efficient to destroy only the thumbs not required (..e if you have 5 thumbs and now u require 3, it would be more efficient to destroy 2, instead of destroying 5, then creating 3 new ones.
Language Found: English
Bugbase Id: none
QA Owner: Ella Mitelman
Resolved by: Ryan Frishberg
Participants: Ella Mitelman, Ryan Frishberg and Tink
Browser: Other (specify version)
JDK: Sun 1.4.x

Sub-Tasks  All   Open   
 Sub-Task Progress: 

 All   Comments      Sort Order:
Tink - [07/23/08 05:17 AM ]
This is a super simple fix. It should be standard through the Flex framework that listeners are removed when items are destroyed.

Ryan Frishberg - [09/04/08 07:16 PM ]
Fixed in 3.0.x branch with change 3108.

I don't think the "removing and then creating extra thumbs" is really a problem when you consider how often this gets called, but feel free to open another bug about it.

Ryan Frishberg - [09/05/08 03:21 PM ]
After some discussion, we decided it's best to just leave out code when it's not necessary. There's no memory leak here, so no need for the extra code.

Revertted the change in CL3123. Marking as NAB since this is not a memory leak. In this case, the event listener adds a reference from thumb to the parent object's handler. However, thumb still has 0 references to it, so it can be GCed as appropriate.

Tink - [09/06/08 12:48 PM ]
"There's no memory leak here, so no need for the extra code."

I'm pretty sure this isn't the case.

The thumb has a reference to it from the listener, therefore both the thumb and the listener are never eligible for garbage collection.

package
{

import flash.display.Sprite;
import flash.events.Event;

public class Listener extends Sprite
{
public function Listener()
{
var sprite:Sprite = new Sprite()
sprite.addEventListener( Event.ENTER_FRAME, onEnterFrame );
}

private function onEnterFrame( event:Event ):void
{
trace( "onEnterFrame" );
}
}

}

The example above is very much like the thumb. The only reference to the Sprite is the listener that was added to it. Due to the listener having a reference, both the spite and listener are never garbage collection.