This content has been marked as final. Show 8 replies
I don't see any removeListeners in there. Garbage collection isn't what you think.
rr, he doesn't need to remove the enterframe listeners because he's using weak references in his addEventListeners.
but the rest of the code contains useless adding and removing children. and there's no code to force gc.
if you're trying to see if a loaded swf is completely removed, you only need one enterframe listener (with a weak reference), one loader and one complete listener. there's no need for any adding/removing of children.
after loading is complete you should see your repeated trace. null your loader and add some code to force gc. your trace statements should stop after a while.
did you checked what you write in adobe devnet?
you said i must null loader but i not only did it but also unloaded that before but event continue his life
i think it is not error of loader class it is gc error for another example of it's errors try this create 2 frame fla file
add one symbole in frame 2 and then add event listener to enterframe event of symbol
with two button add navigation for going to frames one and two
you will see each time you enter frame 2 another eventlistener will add to symbol and for example if your listener rotate symbol by one degree you will see each time speed will increase because each of them rotate object 1 degree
kglad, that is good to know. I guess I've got to run a few more experiments in AS3! Thanks.
maybe I don't understand things correctly here. I thought using weak references is good practice. But it doesn't mean the event listeners get removed from memory until the garbage collector runs (ex_manager - the fact that the GC doesn't run straight away is not a bug AFAIK).
I know you can force GC to run, but only in a way that makes sense for testing from the examples I've seen.
So, my assumption is that, while its great to be able to use weak references for events, its a form of 'safety net' and you should still explicitly remove them. Is this right or wrong? I too am about to dive headlong into as3...
using weak references should be a good practice, but it doesn't work. i didn't realize that until i started testing a few days ago.
i tested weak reference usage for the dictionary class months ago and found that didn't work, either.
you still need to remove listeners (even weakly referenced ones) to ready an object for gc.
kglad: great, thanks for clarifying that.