سؤال

Do I have to worry anymore about all the listeners and class instances added to a movie clip that is no longer displayed on the scene?

I'm asking because I want to know if it makes sense to clean up after I'm done with a movie clip's instances on the scene.

هل كانت مفيدة؟

المحلول

Yes, you need to clean up.

Event listeners will keep the clip from being garbage collected if they are not removed.
Alternately, you can use weak event listeners. Then the listener will not prevent garbage collection as long as all other references to the clip are removed.

AS3: Weakly Referenced Listeners

نصائح أخرى

Realistically it depends on your app/swf file.

If your app is complicated/extensive and will be used for a lengthy session time wise then yes, you should be manually removing all references, stopping animations and nulling the instances.

Remember that even when the instance is off stage or removed from the display list, it still uses CPU and memory resources.

It is good working practice to do this but not really essential for smaller projects.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top