Hi CyberHawk,

If you do not remove the event listeners on an object it will not be
Garbage Collected and will remain in memory. That means that an
ENTER_FRAME handler will keep running. That can affect the memory but
also performance of your app. Obviously for persistent interactions
(like keys) on the stage you don't need to remove them unless you
don't need them anymore. But when you have objects that you plan on
creating and removing dynamically (like containers for sections on a
site or images in a carousel) you should build a way to remove all the
events once you are disposing of that object. You can just add 2
functions to classes that will handle this addAllEvents() and
removeAllEvents(). Just make sure all the events added in addAllEvents
are removed in removeAllEvents.

But the best way to handle this is to avoid creating garbage in the
first place! Use Object Pools where ever possible. Google it, there
are vary simple implementations you can apply to your projects. By
recycling your objects, like those using BitmapMaterials, you can save
yourself a lot of hair lost in debugging memory issues :)

The HYPE framework has a lot of Object Pools demo and Lost In
Actionscript has a Basic Object Pool class in its repository.

ath.

Jerome.

Reply via email to