01 October 2008

Garbage collector

I was trying to optimizing my MobileCairngorm (more info soon) when I googled to a very useful article on Adobe's Mobile Developer Center : Memory management and optimizations in Flash Lite
So bad I missed this one (from June 2007!)
Of course, others parts of the article are interesting but I was fighting with memory so...

Note some parts of this article can also be found in Flash Lite Help (link to LiveDoc)

The two things I noticed are
  1. GCollector runs every 60secondes...I was unable to see it works on Device Central's memory monitor.
  2. You can delete classes for unloaded SWF.

the point 2 is very interesting so I made some tests

  • delete class B which inherits from class A will only delete class B
  • it seems object of deleted class B will still have class A properties, events, functions (read will become something like an object of class A)
  • article talk about loaded SWF, so I tried with movieclips inside my main swf, to see if it works the same : if I delete a class on movieclip 1 (on unload) and then attach movieClip 2, this new movieclip doesn't reload the class. It seems a deleted class is lost for ever...in the SWF.

1 comment:

Hays said...

When you say delete the class... do you mean the object? Or is the class actually gone? For instance... if I have a MovieClip that instantiates a "monkey class". I delete that Movieclip and I try to create another instance of Monkey I won't be able too?

... I'm confused.