Is removeEventListener as necessary as dealloc?
I know it’s possible to get memory leaks in AS3 and I’m just wondering if not removing Event Listeners is one of those ways.
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Yes, I created a huge project without removing any eventListener, and after long use it really get a lot of memory…
Any object with a strong reference will not be garbage collected, until the strong reference is removed…. this apply to eventlistener, bindings, etc…
You can removeEventListener manually using the
removeEventListener(Event.TYPE, function)or using the weakReference…
Adding an Event Listener with WeakReference you simply need to add more parameters to the addMethod…
obj.addEventListener(Event.Type, Function, false, 0, true)addEventListener(type:String, listener:Function, useCapture:Boolean=false, priority:int=0, useWeakReference:Boolean=false):void