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…



Please, explain your last phrase about mamory fragmentation. As I see if you clear memory from “3 objects in the size of 2 KB ” , so you have 6 KB free space (3*2=6, Isn’t it?!)
Hi! there.
I have a quick question for you.
Whenever I try to use “delete” and “null” in Flash lite 1.1, Flash 8 says to me that I have to export my movie as Flash 5 which means that there are no delete and null in flash lite 1.1.
So, my question is this article is releated with only flash lite 2.0?
2dongwook
You are right, this article is releated with only Flash Lite 2.0.
IMHO, Flash lite 1.1 can not be used as real developers platform.
i don’t agree.
FL1.1 features an old AS language which is hard to code, but it performs better. also it’s Flash4 based loadvars api takes less memory/resources as compared with FL2’s XML.
FL1.1 is far better than FL2.0 in performance and memory consumption. i’ve already posted a blog post about animations: http://www.orison.biz/blogs/chall3ng3r/
and in my next article i’ll discuss further on animations and memory consumption.
// chall3ng3r //
Hi, it might seem a little weird that 3*2KB don’t equal space for a 6KB object, but this has to do with fragmentation; the memory area from 3 objects taking 2 KB each is not necessarily contiguous. It may look like this in the heap:
| class a object (2kb)
| class b object (3Kb)
| class a object (2 kb)
| class c object (1 kb)
| class a object (2 kb)
If you delete / free / nullify all the class a objects, it is true that there is a total area of 6 KB freed. But as it looks like this:
(whoops, premature post ;))
…as it looks like this:
| free 2KB
| class b object (3KB)
| free 2KB
| class c object (1 Kb
| free 2KB
, it is not possible to fit one 6 KB object into the free space…
[...] Some links on garbage collection in Flash Lite: Flash Lite memory management (LiveDocs) Comparison between Java ME and Flash Lite Flash Lite memory management [...]
Question: if in a class instance a new instance is made of a different class (eg: menu -> menuitem), is the menuitem class removed if the menu is removed? I made a demo for a enhanced phonebook, but something is floading the memory :(
Hello! Good Site! Thanks you!
Is there a deliberate way to set the amount of dynamic heap memory avaliable to the application?
I’m currently developing a graphics intensive prototype application in Flash Lite 2.1 on a Windows Mobile 5.0 enabled device. The actual device has 64 MB avaliable, but I haven’t found any place in the discussions or documentations mentioning how to make a deliberate allocation of more than than the automatically assigned amount of memory. Does anyone know if this is possible, and if so, how to achieve this?