Garbage colleciton of Flex : with Example

Flash Player provides built-in garbage collection that frees up memory by destroying
objects that are no longer used. To ensure that the garbage collector destroys your
unused objects, remove all references to that object, including the parent’s reference
to the child.

On containers, you can call the removeChild() or removeChildAt() method to remove
references to child controls that are no longer needed. The following example removes
references to button instances from the myVBox control:

example:

<![CDATA[
private function destroyButtons(e:Event):void {
myVBox.removeChild(b1);
myVBox.removeChild(b2);
myVBox.removeChild(b3);
}
]]>

You can clear references to unused variables by setting them to null in your ActionScript; for example:

myDataProvider = null

To ensure that destroyed objects are garbage collected, you must also remove event
listeners on them by using the removeEventListener() met

3 Responses to “Garbage colleciton of Flex : with Example”

  1. Neelam Sanjeev Says:

    Hi

  2. Neelam Sanjeev Says:

    Hi,
    I want to know how to garbage collect strings

  3. gyani Says:

    yes yes neelam, i also want to know how objects r garbage collected. plz help me….

Leave a Reply