actionscript-3flashgarbage-collectionosmf

How to recycle(Garbage Collection) "static const Object" in Action Script 3.0?


When I use OSMF to develop a Player Module(Standalone SWF File) that I can load/unload it dynamically, I found that I can't recycle it completely.
I have checked the variaties of OSMF,like MediaPlayerSprite, MediaElement, MediaContainer etc have been recycled, that means the number of Instance that created by those class is Zero.But there are some "static const" that can't been recycled.
For example:

public static const ALL_TYPES:Vector.<String> = Vector.<String>

in Class MediaTraitType.

private static const MEDIA_TYPES_SUPPORTED:Vector.<String> = Vector.<String>([MediaType.VIDEO]);
private static const MIME_TYPES_SUPPORTED:Vector.<String> = Vector.<String>

in Class NetLoader.
Because of this, everytime I load a new Player Module, those instance can't be recycled but increase.
I know that I can keep a Player Module but not to load/unload everytime.But I really want to know whether there is a way to solve this thing.


Solution

  • If all that consts are located inside a loaded swf they will be removed with that swf after loader.unloadAndStop() call

    I also found this question about the issue with sounds in the unloaded swf while looking for the reference which might be useful