ABSTRACT

The reference counting technique of the GC happens automatically and immediately when the number of references to an object changes. However, because mark sweeping requires running the entire length of the object tree in memory, it is a very intense effect on the system and is only run periodically . In my experience, this is usually pretty frequently on decent machines, but it cannot be counted on for split-second accuracy. Don’t worry, though — there are a few things you can do to help the garbage collector run thoroughly and effectively:

Be diligent about removing your references to objects If you have multiple references to objects in your classes, I

suggest writing a function called cleanUp in classes that contain a lot of references. This function can perform such tasks as setting references to null and emptying arrays. By helping the reference counting mechanism of the GC, you’ll make the entire process easier on Flash and therefore less taxing on your game.