Adobe released beta 2 of Flash Player 10 this afternoon, and I was very excited to see in the release notes that they have added in a new method of the Loader class, unloadAndStop(). From said release notes:
unloadAndStop — This new ActionScript 3.0 API adds unload functionality similar to the unload behavior in ActionScript 2.0. After calling unloadAndStop on loaded content it will be immediately removed stopping all audio, removing eventListeners, and becoming inaccessible through ActionScript.
In short, this should make it much simpler to free a loaded SWF for garbage collection, as opposed to having to resort to hacks like SoundMixer.stopAll() and then praying that the content isn't just floating around somewhere waiting to be picked up.
Grant Skinner had written a post about Flash Player 9's inability to completely free loaded content from memory and force garbage collection. It became a very active post with almost 60 comments, including some from the Flash Player development team.
In the comments of Grant's post I read about an additional item that has found its way into FP10 beta 2: calling System.gc() will now work in all Flash Players, not just the debug versions as stated in the AS3 documentation:
System.gc()
Language Version : ActionScript 3.0
Runtime Versions : AIR 1.0, Flash Player 9.0.115.0Forces the garbage collection process.
For the Flash Player debugger version and AIR applications only. In an AIR application, the
System.gc()method is only enabled in content running in the AIR Debug Launcher (ADL) or, in an installed applcation, in content in the application security sandbox.
Once again, great job Adobe at listening to the requests of your developers!









