Wednesday, February 28, 2007

Severe memory issues in flash with JPG sequences

So when doing a new (first) project for Heineken (for my company QI) we run in a big issue with flash and the carbage collector. It seems when you have a JPG sequence on stage the JPG's stays in memory even when attached and removed out of the library. We used a jpeg sequence instead of fullscreen video because JPEG tends to have smoother playback for our 3D animations.

But think 100 jpeg images of 1014 x 690 resolution. Flash needs 3MB to show one frame. So after about 100 jpeg's flash needed 300MB virtual memory, this memory never got freed by the carbage collector .. So the slower computer with not that much RAM would suffocate.

After doing some tests, it seems when loading an external SWF in a mc (with a linked sequence in library). And after loading, attaching the linked sequence in that mc. The MC can be removed and memory gets freed.

For now we have cutted the sequence in different parts, so after playing a part it can unloaded.

  • We have for example 3 sequences in library in a single SWF called sequence.swf.
  • we create 3 container MC's where we load in the same SWF (cache :>)
  • we start the seqeunce and attach in container1 > sequence1 after playing the first sequence we remove container1 and attach sequence2 in container 2.
  • and so on..

This heavely relies on cache and is a not so nice solution so ANYONE got a better one I would love to hear it.

NYLS