# Removing a DisplayObject from memory

**URL:** <https://forum.kirupa.com/t/removing-a-displayobject-from-memory/226065>\
**Category:** flash\
**Created:** [May 17, 2007, 10:15pm UTC](https://forum.kirupa.com/t/removing-a-displayobject-from-memory/226065 "2007-05-17T22:15:16Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![kiosk77](https://avatars.discourse-cdn.com/v4/letter/k/8c91f0/32.png) [@kiosk77](https://forum.kirupa.com/u/kiosk77)\
**Post date:** [May 17, 2007, 10:15pm UTC](https://forum.kirupa.com/t/removing-a-displayobject-from-memory/226065/1 "2007-05-17T22:15:16Z")

</div>

I know that if you register to the ENTER\_FRAME or any of the keyboards events you have to unregister before your DisplayObject can be collected by the GC but how about other events???

Do I need to remove these listeners too? If yes, it seems like a lot of extra work… Anybody know the answer? thank you

```auto

public class IconObject extends Sprite {
        
        public function IconObject() {
            loader = new Loader();
            
            loader.contentLoaderInfo.addEventListener( IOErrorEvent.IO_ERROR, onLoadError );
            loader.contentLoaderInfo.addEventListener( Event.INIT, onLoadInit );
            addEventListener( MouseEvent.MOUSE_OVER, onRollOver );
            addEventListener( MouseEvent.MOUSE_OUT, onRollOut );
            
        }

```
