# AS3 variable declarations

**URL:** <https://forum.kirupa.com/t/as3-variable-declarations/288227>\
**Category:** flash\
**Created:** [May 13, 2009, 3:44am UTC](https://forum.kirupa.com/t/as3-variable-declarations/288227 "2009-05-13T03:44:45Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![pizzapancakes](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/pizzapancakes/32/2324_2.png) [@pizzapancakes](https://forum.kirupa.com/u/pizzapancakes)\
**Post date:** [May 13, 2009, 3:44am UTC](https://forum.kirupa.com/t/as3-variable-declarations/288227/1 "2009-05-13T03:44:45Z")

</div>

I was thinking about how to streamline my code the other day and looked through my classes checking for possible memory leaks. I wonder when are variables declared inside of methods clear for garbage collection? or are they not and just hang around?

For instance if I have a class like this:

```auto

public class MyClass {

    public function myClass(){}

    private function someMethod():void{
          var a:SomeOtherClass = new SomeOtherClass;
    }

}

```

Since the variable was declared without reference into the class how long does it stay in Flash’s memory, or does it stay indefinitely because it cannot be nullified? Thanks for the hlep.
