# Object lifespan within a Scope (Garbage Collection)

**URL:** https://forum.kirupa.com/t/object-lifespan-within-a-scope-garbage-collection/238140
**Category:** flash
**Created:** [September 7, 2007, 3:37pm UTC](https://forum.kirupa.com/t/object-lifespan-within-a-scope-garbage-collection/238140 "2007-09-07T15:37:17Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![Wedge\_Man](https://avatars.discourse-cdn.com/v4/letter/w/f07891/32.png) [@Wedge\_Man](https://forum.kirupa.com/u/Wedge_Man)
#### Post date: [September 7, 2007, 3:37pm UTC](https://forum.kirupa.com/t/object-lifespan-within-a-scope-garbage-collection/238140/1 "2007-09-07T15:37:17Z")

</div>

Hey all,

So take this basic function:

```auto
 
public function createNew() {
 
var myObj = new AwesomeObject();
 
myObj.setX(30);
myObj.setY(30);
 
}

```

Since i’m using the “new” keyword, I’m creating a new Instance of my AwesomeObject and then i’m accessing some of the properties.

However, once i exit the function, I have no way to reference my AwesomeObject instance. Does Flash then consider this garbage? And will then clean it up at some indeterminate time?

Or do I have to explicitly put in another line such as:

myObj = null;

Thanks!
