Lets pretend you have a popup that you want to show when a button is clicked, as in the following example:
<?xml version="1.0" encoding="utf-8"?> <s:WindowedApplication xmlns:fx="http://ns.adobe.com/mxml/2009" xmlns:mx="library://ns.adobe.com/flex/mx" xmlns:s="library://ns.adobe.com/flex/spark"> <s:Button label="Some Button that pops something up" horizontalCenter="0" verticalCenter="0" click="popup.displayPopUp = true;"/> <s:PopUpAnchor id="popup" right="0" bottom="0"> <s:Group> <s:Rect width="50" height="50"> <s:fill> <s:SolidColor color="0xFF00FF"/> </s:fill> </s:Rect> </s:Group> </s:PopUpAnchor> </s:WindowedApplication>
How do you easily manage when the popup is closed in this case?
A new article was recently published on adobe’s devnet providing another recap of how memory is managed by Flash. I wanted to reiterate the importance of diligently clearing the stack memory of references to the heap memory in order to minimize the work of the collector in the Mark and Sweep phase.
You, as the developer, can optimize your code by helping the Mark and Sweep phases of garbage collection occur less often. By keeping your stack references cleared of objects on the heap, the zero count table algorithm can clean up the memory before mark and sweep has to occur.