GC on occurs on alloc if it needs to, so it won't always recover memory
right away.  See the GC preso on my blog for more info.

________________________________

From: [email protected] [mailto:[EMAIL PROTECTED] On
Behalf Of Manish Jethani
Sent: Thursday, May 03, 2007 3:34 PM
To: [email protected]
Subject: Re: [flexcoders] Removing Popups



On 5/4/07, Carlos Rovira <[EMAIL PROTECTED]
<mailto:carlos.rovira%40gmail.com> > wrote:

> Could you post some example, I'm finding this issue too, and want to
know
> more about this since maybe we are using it in a bad way.
> when I remove the popup with PopupManager I suppose I'm removing it
form
> memory, or I'm only removing from displaylist

When you call removePopUp(), you're removing the pop-up from the
display list. There's no direct memory management in Flash/Flex.
Assuming there are no other references to that window, though, the
window should be garbage collected.

Now that's the thing -- looks like there's some reference to it
somewhere.

Here's a simple example without any event listeners.

<?xml version="1.0"?>
<mx:TitleWindow xmlns:mx="http://www.adobe.com/2006/mxml
<http://www.adobe.com/2006/mxml> "
xmlns="*" width="400" height="300" title="Window">
<mx:SWFLoader source="AYB3.swf" width="100%" height="100%" />
</mx:TitleWindow>

And the window is popped-up here.

>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml
<http://www.adobe.com/2006/mxml> "
xmlns="*">
<mx:Button label="Launch Window" click="launchWindow()" />
<mx:Button label="Remove Window" click="removeWindow()" />

<mx:Script>
import mx.core.*;
import mx.managers.*;
private var window:IFlexDisplayObject;
private function launchWindow():void
{
window = new MyWindow();
PopUpManager.addPopUp(window, this);
PopUpManager.centerPopUp(window);
}
private function removeWindow():void
{
PopUpManager.removePopUp(window);
window = null;
}
</mx:Script>
</mx:Application>

I'm setting window to null. In theory it should be garbage collected
and the .swf content in the window should stop playing (no sound
should be heard). This doesn't happen.


 

Reply via email to