Release application domain from main SWF

1k views Asked by At

i like to know that there is way to remove all data after unload swf .

Calling Loader.unloadAndStop(); remove content and loaded bytes , but loaded classes stays in application domain .

If i load it to separated new ApplicationDomain , gc is going to collect them after unload and remove all references ?

1

There are 1 answers

2
AudioBubble On BEST ANSWER

For starters, classes you loaded into domain don't stay in memory when unloaded unless you keep references. So, if you did something like:

private static var foo:Class = 
    loadedSWF.loaderInfo.applicationDomain.getDefinition("Foo");

Then, obviously, it will stay in memory. There are some other things to be aware of, depending on the player version the behavior of registerClassAlias() changed in a way that if it was called from the loaded SWF, the alias would be registered in the parent domain, thus there would be no way later to unload the class, unless you register the same alias for another class. In some later, but not the last version, it would properly register classes in the correct domain, but it broke some people's code... sigh and today the behavior is sort of unpredictable, it will try to decide what domain is trying to register the alias based on that class uses in that domain, which, of course, may differ at runtime...