private function closePopUp():void
myObject = null;
always remember to remove any event listeners listeners on the object
then set it to null.
As said it is always good to make sure that you remove all the eventListeners associated with any objects when you clear them especialy with PopUp's otherwise it will throw you in unknown darkness as why these unusual things appear as your PopUp component becomes complex in functionality and includes many eventListeners.
So you should do this..
private var myObject:MyObject;
private function openPopUp():void
myObject = new MyObject();
PopUpManager.addPopUp(myObject, this, true);
private function closePopUp(e:Event):void
//Remove all the eventListeners associated with the myObject Object
myObject = null;
Also take into account that the Garbage Collector doesn't jump over an unreferenced object straight away, it has some specified routines.
And I have actually seen screencasts about how the garbage collector sometimes only runes, when It needs to allocate new memory.
This is not the one, but maybe it's also mentioned in here:
And as the other states, ALWAYS cleanup you eventlisteners.
Thanks for your responses.
Is there a way to see what event listeners are still present even after the initial object variable has been set to null?
You should think of the addEventListener as introducing a new reference, See:
When you no longer need an event listener, remove it by calling
EventDispatcher.removeEventListener(); otherwise, memory problems might result. Objects with registered event listeners are not automatically removed from memory because the garbage collector does not remove objects that still have references.
But no, I don't think there are any way, but why also do it?
You coded it, so you should know which listeners it has
The profiler will show you what listeners are still attached, although
FP10.1 is not reporting all listeners, so try 10.0.
Will using FP 10.1 affect AIR applications too? How come FP 10.1 doesn't report all events?
I haven't checked the recent builds of AIR, but they were not reporting
listeners to the NativeApplication, IIRC.
I think I just saw that they fixed that bug for the 2.6 release.