# Storing a local var, what happens in memory?

**URL:** <https://forum.kirupa.com/t/storing-a-local-var-what-happens-in-memory/279471>\
**Category:** flash\
**Created:** [January 15, 2009, 12:11am UTC](https://forum.kirupa.com/t/storing-a-local-var-what-happens-in-memory/279471 "2009-01-15T00:11:27Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![furyan\_be](https://avatars.discourse-cdn.com/v4/letter/f/3da27b/32.png) [@furyan\_be](https://forum.kirupa.com/u/furyan_be)\
**Post date:** [January 15, 2009, 12:11am UTC](https://forum.kirupa.com/t/storing-a-local-var-what-happens-in-memory/279471/1 "2009-01-15T00:11:27Z")

</div>

Hi, im trying to get a deeper understanding on how as works, I was wondering:

> 

for(var i:int = 0; i \< 100; i++)  
{  
[INDENT]var s:Sprite = new Sprite();  
s.name = “sprite”+i;  
addChild(s);  
[/INDENT]}

var s is a reference to the the new Sprite  
new Sprite is stored inside memory at some place  
var s is also stored inside memory but only takes a small amount of space because it only needs to point to new Sprite?

the second time the loop runs, will the old var s be overwritten in memory? or will it be asigned to a new position in memory?

would it be beneficial if i typed something like this?

> 

for(var i:int = 0; i \< 100; i++)  
{  
[INDENT]var s:Sprite = new Sprite();  
s.name = “sprite”+i;  
addChild(s);  
[COLOR=YellowGreen]s = null[/COLOR]  
[/INDENT] }
