Thursday, April 2, 2009

Memory Leak in Flex 3.

Oklahoma... so to tell that there Holds a memory leak in Lists and Grids is a little spare as they all inherit from one family, ListBase, which is where the job is, but a little of redundancy can be attention-getting.


Anyways... recently I was running an issue registered by one of our examiners, and bumble across a awful small memory leak in the3.2 SDK. Adobe 's already rectified the job in the3.3 nightlies, but I believed I 'd post my determinations here on the opportunity that anyone else necessitates the muddle in their3.2 SDK.


The job is a little family named StageEventProxy. SystemManager makes an example of StageEventProxy passing thereto your auditor whenever one of the undermentioned types of events is listened for from SystemManager:


  • MouseEvent.MOUSE_MOVE

  • MouseEvent.MOUSE_UP

  • MouseEvent.MOUSE_DOWN

  • Event.ACTIVATE

  • Event.DEACTIVATE


The job is that StageEventProxy holds a difficult mention to your attender map. This intends that when trash pickup runs, that auditor and the object its attached to will ne'er get labelled for trash pickup.


Now, you 're belike believing, `` I 've ne'er added any of those hearers to SystemManager so I 'm free and clear. Woot! '' Unfortunately you 're not off the hook but yet. Adobe adds a MOUSE_UP hearer to SystemManager in ListBase 's mouseDownHandler ( ):




systemManager.getSandboxRoot().addEventListener(MouseEvent.MOUSE_UP, mouseUpHandler, true, 0, true);

The outcome of this line is that any object that Holds an example of a subclass of this category ( a speedy hunt through the rootage codification revealed Listing, DataGrid, AdvancedDataGrid, and TileList ) will ne'er be scraps compiled once the user holds snapped on any of the rows in the listing. Additionally, because all UIComponents maintain a difficult mention to their parent factor, the garbage man will too overlook to clean upwards any of your listing 's roots in the papers hierarchy.


The deductions of that for most people are that lists in pop-ups will do the integrality of your pop-up to ne'er get refuse accumulated. Here at Workday its a much biggerer issue, yet. Our pages are dynamically maked based on XML page definitions we get from the waiter. These pages are likewise dynamically unloaded when a new page is haved. As a outcome of the fleck for this mess, we 've seen dramatically cutted memory employment over clip in our Flex applications.


Here Holds the perpetrator so you can see what was moving on:




////////////////////////////////////////////////////////////////////////////////
//
// ADOBE SYSTEMS INCORPORATED
// Copyright 2003-2006 Adobe Systems Incorporated
// All Rights Reserved.
//
// NOTICE: Adobe permits you to use, modify, and distribute this file
// in accordance with the terms of the license agreement accompanying it.
//
////////////////////////////////////////////////////////////////////////////////

package mx.managers.systemClasses
{

[ExcludeClass]

import flash.display.Stage;
import flash.events.Event;

/**
* An object that filters stage
*/
public class StageEventProxy
{
private var listener:Function;

public function StageEventProxy(listener:Function)
{
this.listener = listener;
}

public function stageListener(event:Event):void
{
if (event.target is Stage)
listener(event);
}

}

}

Here Holds the updated version Adobe 's including in the3.3 SDK:




////////////////////////////////////////////////////////////////////////////////
//
// ADOBE SYSTEMS INCORPORATED
// Copyright 2003-2006 Adobe Systems Incorporated
// All Rights Reserved.
//
// NOTICE: Adobe permits you to use, modify, and distribute this file
// in accordance with the terms of the license agreement accompanying it.
//
////////////////////////////////////////////////////////////////////////////////

package mx.managers.systemClasses
{

[ExcludeClass]

import flash.display.Stage;
import flash.events.Event;
import flash.utils.Dictionary;

/**
* An object that filters stage
*/
public class StageEventProxy
{
private var weakRef: Dictionary = new Dictionary(true);

public function StageEventProxy(listener:Function)
{
this.weakRef[listener] = 1;
}

public function stageListener(event:Event):void
{
if (event.target is Stage)
{
for (var p:* in weakRef)
{
var f:Function = p as Function;
f(event);
}
}
}

}

}

And eventually... Here Holds a fleck file you can come by your Lib brochure that will lick the job: PATCH FILE


Related posts:
Michael Stanley Band - Heartland

George Benson - The Masquerade Is Over

Richard Clayderman - The Golden Collection

Soundtrack - Various Artists - Georges Delerue - 30 Ans De Musique De Film (Cd 1)

Furia - Piece Of Paradise