# Garbage collector

**URL:** <https://forum.kirupa.com/t/garbage-collector/320250>\
**Category:** Uncategorized\
**Created:** [March 18, 2011, 4:53am UTC](https://forum.kirupa.com/t/garbage-collector/320250 "2011-03-18T04:53:55Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![tbo](https://avatars.discourse-cdn.com/v4/letter/t/7feea3/32.png) [@tbo](https://forum.kirupa.com/u/tbo)\
**Post date:** [March 18, 2011, 4:53am UTC](https://forum.kirupa.com/t/garbage-collector/320250/1 "2011-03-18T04:53:55Z")

</div>

if this is my whole code and only button1 is clicked… then i sit for a few minutes, the garbage collecter should dump the _Truck_right?

```php
var truck:MovieClip= new Truck();
this.addChild(truck);

stage.addEventListener(MouseEvent.CLICK, clicked);

function clicked(e:MouseEvent)
{
    if (e.target == button1)
    {
        this.removeChild(truck);
        truck = null;
    }
    else if (e.target==button2)
    {
        var newtruck:MovieClip= new Truck();
        addChild(newtruck);
    }
}

```

1. am i doing something wrong with that…

2)air for android with gpu mode blits instances of the same Display Objects from 1 source of that object type. (including movieClips and their timelines, yey)

Of course this example creates 1 truck right away, but if i wait for the app to start for a bit, add a first time instance of a display object, you can clearly see fps dip for a sec as it writes the first one to memory as expected, all future instances are fast as its automatically blitting from that pixel buffer created for the _Truck_ object

So here’s my issue:  
Click button1 …wait a while  
Click button2 , the item is instant, telling me the pixel buffer written by the first _Truck_ is still alive and well.

So as i asked before, am i doing what is needed for gc, and if so, how would i dump the pixel buffer to free up ram?

[edit]  
assuming a movieClip in library exported as “Truck”  
and 2 buttons sitting on stage
