----- Original Message ----- From: "Beach Boy" <[EMAIL PROTECTED]>
To: <flashcoders@chattyfig.figleaf.com>
Sent: Tuesday, September 02, 2008 1:16 PM
Subject: [Flashcoders] Memory usage and bitmapdata issue in flash game design


We have a huge movieclip of 5000 by 5000 pixels with different (transparant)
layers.
We can make an instance of the movieclip and work with it, we can move
layers, scale them, ...

But as soon as we add the MovieClip to the stage the ram memory-usage jumps
to 200 MB!
My guess is that flash retrieves all the bitmapdata from the MovieClip (all
25 million pixels) so it can display it. And all this data takes up around
200MB.

For cpu performance and obviously the memory-issue we use bitmapdata with
clipRect to extract a single 'screenshot' of 600 by 400 and add that to the stage instead of the entire mc. At first the memory-usage is reasonable, but
as we start to explore the map it goes up again. It keeps rising to the
point that, when you have explored the entire map, the memory-usage is back
at around 200MB, same as when we added the mc to the stage.

We use BitmapData.dispose() but this doens't seem to help either as the
garbage-collector doesn't free up the ram instantly.
We tried using tiles, we cut the entire mc up in tiles and added and removed
the necessary tiles, but again, the memory starts low and rises as we
explore the map.

It's hard to believe that all those papervision-applications run so smoothly
using BitmapData while we only use a couple large jpg's and have such
extreme memory-usage.
Is there any way to make the garbage-collector pass (we use flash player 9)
or reduce the memory-usage?

If you're using AS3, the GC won't remove anything that has a reference to it. There's already been considerable discussion about this here and on the flexcoders list and no doubt googling AS3 and garbage collection will be very revealing.

Sounds as though you are gradually collecting the bitmap info until you are back to the whole 200MB.

200MB is a LOT of bitmap data for a flash game IMHO and maybe you can look at reducing it.

Paul



Any help or tips would be greatly appreciated!
_______________________________________________
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

_______________________________________________
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

Reply via email to