[Flashcoders] Memory usage and bitmapdata issue in flash game design

2008-09-02 Thread Beach Boy
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?

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


Re: [Flashcoders] Memory usage and bitmapdata issue in flash game design

2008-09-02 Thread Paul Andrews
- 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


Re: [Flashcoders] Memory usage and bitmapdata issue in flash game design

2008-09-02 Thread Ashim D'Silva
I'd really like to see where this thread goes because efficiency in Flash is
a touch subject I guess.
First suggestion I have is stop using MovieClips. They're kinda useless.
Move as far down the chain as possible... to bitmapData and shapes. The
simpler you go and the more low level stuff you write, the better it gets.
We wrote an animated bitmap class for a flash game we wrote, and we got more
than 5000 of them running without a problem (in the world, not on screen).
The display list and event listeners are two other places that chew up a lot
of power. I've been tempted many a time to eliminate the display list
entirely and do everything rendered to a bitmapData and then display that -
not sure if it would make a difference but it would be a fun experiment, and
a telling one.
Hope this helped... its two cents from a designer and part time coder, so
don't trust it too much!

Cheers,

Ashim

2008/9/2 Beach Boy [EMAIL PROTECTED]

 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?

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




-- 
The Random Lines
My online portfolio
www.therandomlines.com
___
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders