moock.org is supported in part by


April 03, 2007

Chapter 14, Paragraphs 1-3, Essential ActionScript 3.0

Here are the first 3 paragraphs of Chapter 14 of Essential ActionScript 3.0

14. Garbage Collection

Every time a program creates an object, ActionScript stores it in system memory (for example, in RAM). As a program creates hundreds, thousands, or even millions of objects, it slowly occupies more and more memory. To prevent system memory from being fully depleted, ActionScript automatically removes objects from memory when they are no longer needed by the program. The automatic removal of objects from memory is known as garbage collection.

Eligibility for Garbage Collection

In an ActionScript program, an object becomes eligible for garbage collection as soon as it becomes unreachable. An object is unreachable when it cannot be accessed directly or indirectly through at least one garbage collection root. The most significant garbage collection roots in ActionScript are as follows:

* Package-level variables
* Local variables of a currently executing method or function
* Static variables
* Instance variables of the programís main class instance
* Instance variables of an object on the Flash runtime display list
* Variables in the scope chain of a currently executing function or method

Posted by moock at April 3, 2007 08:13 PM