As we know from Flash Lite reference, threre is a mechanism of automatic clearing of memory , named “Garbage Collection“. Garbage collector clears from memory any objects that your application no longer references, but in difference from other programming languages, in the ActionScript is not available opportunities to call garbage collector from code - this process is executed automatically every minute or whenever memory usage of your application increases by 20% or more … practically it not so good as macromedia promise. In article “Managing application memory” on macromedia site are given some advice about that how rationally to work with memory. I shall tell about them and I’ll add it with my remarks.

First tip : “Limit the use of global variables, because they are not garbage collected if the movie clip that defined them was removed.” - so, you can prepare movie clips with different set of global variables and after remove each of them when his variables no longer needed. I think it’s clear.

The second tip is more complex. To clear object’s memory macromedia advice to set to null the variable that references the object when you are finished with the object. For example,

MyButton myBt = new MyButton();

some code

myBt = null;

This is good technics which is used by many programmers, but it works in case if you have only one such type object (in our example only one object of MyButton class) . In other cases, this reduces the reference count and, only when the reference count reaches zero, the object’s memory can be reclaimed by Flash Lite garbage collector. So, remember to set all unused object references from same class to null,
to help out the garbage collector.

And at the end, use the delete statement to free the memory from timeline variables.

One important thing - a fragmentation of memory,I’ll tell in following post, remember only that fact, that having released memory from 3 objects in the size of 2 KB you cannot take this place with new object in 6 KB. What to do I shall tell later…