# How to detect/remove ALL (possibly unknown) event listeners on an object?

**URL:** <https://forum.kirupa.com/t/how-to-detect-remove-all-possibly-unknown-event-listeners-on-an-object/299920>\
**Category:** flash\
**Created:** [November 12, 2009, 4:50pm UTC](https://forum.kirupa.com/t/how-to-detect-remove-all-possibly-unknown-event-listeners-on-an-object/299920 "2009-11-12T16:50:04Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![robertnyc](https://avatars.discourse-cdn.com/v4/letter/r/a6a055/32.png) [@robertnyc](https://forum.kirupa.com/u/robertnyc)\
**Post date:** [November 12, 2009, 4:50pm UTC](https://forum.kirupa.com/t/how-to-detect-remove-all-possibly-unknown-event-listeners-on-an-object/299920/1 "2009-11-12T16:50:04Z")

</div>

I’m having problem with garbage collection in a large, not-so-well-written project that I didn’t start. I am getting memory leaks – and want to make sure that all event listeners on the offending objects are removed. I’ve gone through the code and done what I can, but still ain’t happening – is there a way in AS3 to take an object and see IF it has an event listener, and to REMOVE that listener – that is, to remove ALL listeners, without knowing what they are? I know if I know what the EVENT TYPE is then I can use hasEventListener() to figure out if it has a listener of that type (although the presupposes I know all the event types being used), but if I don’t know the function that it’s subscribing to then I can’t remove it.

Or is there some other way to simply nullify an object for GC? I’ve changed all listeners to weak – but I think (since the offending objects are FLVPlaybacks) that something in the flash internal setup is still listening to my object (I’ve gleaned this from FB 4 profiler which I’ve used in external mode). I would just, at this point, like to see what’s going on.

Thanks

Robert
