# Garbage collection

**URL:** <https://forum.kirupa.com/t/garbage-collection/284779>\
**Category:** Uncategorized\
**Created:** [March 23, 2009, 4:27pm UTC](https://forum.kirupa.com/t/garbage-collection/284779 "2009-03-23T16:27:55Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Alex\_Prokop](https://avatars.discourse-cdn.com/v4/letter/a/919ad9/32.png) [@Alex\_Prokop](https://forum.kirupa.com/u/Alex_Prokop)\
**Post date:** [March 23, 2009, 4:27pm UTC](https://forum.kirupa.com/t/garbage-collection/284779/1 "2009-03-23T16:27:55Z")

</div>

Hi, I haven’t managed to find a huge amount of info on the AS3 garbage collector although gskinners blog has some good articles. My question really is this:

Will the garbage collector automatically free resources from an object’s members (assuming I have no references to them elsewhere and have removed all event listeners) once I remove the parent object from the stage and set its reference to null (as Java behaves)?

Or should I explicitly remove the member objects from my parent object and null them also?

ie.

```auto
public class A extends Sprite{

     private var bInstance:B;

     public function A() {

         bInstance = new B();
         this.addChild(bInstance);

     }

     //should I implement a function such as this or is it completely unnecessary?

     public function destructor():void {

         this.removeChild(bInstance);
         bInstance = null;

     }
}

```

Cheers,  
Alex
