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

Advertisements

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

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: