Is there a simple way to clean up all active listeners on an object so that it can be garbage collected?
e.g. myDiv.removeAllListeners()
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.
Listeners on an object won’t prevent it from being garbage collected. You can simplify it like this:
You have an array. You put functions (listeners) in the array and then throw away your reference to the array. The array is referenced by nothing, so it can be garbage collected. Also, there are no more references to the functions, so that isn’t an issue either.