Skip to main content
Known Participant
December 6, 2013
Answered

BitmapData Limit

  • December 6, 2013
  • 16 replies
  • 2444 views

Hi,

I'm getting a flash error when creating many BitmapDatas (I'm not talking about one bitmap that is too big).

I created for you a copy-paste class that reproduces the error.

Simply create an Issue class file and copy paste that code, then instantiate that class in your main class (new Issue()).

package

{

          import flash.display.Bitmap;

          import flash.display.BitmapData;

          import flash.display.MovieClip;

          import flash.events.Event;

          public class Issue extends MovieClip

          {

                    private var mc:MovieClip;

                    public function Issue():void

                    {

                              addEventListener(Event.ENTER_FRAME, eachFrame);

                              mc = new MovieClip();

                    }

                    private function eachFrame(e:Event):void

                    {

                              for (var i:uint = 0; i < 100; i++)

                              {

                                        createBitmap();

                              }

                    }

                    private function createBitmap():void

                    {

                              var bm:Bitmap = getBitmap();

                              mc.addChild(bm);

                    }

                    private function getBitmap():Bitmap

                    {

                              var bmd:BitmapData = new BitmapData(500, 500);

                              return new Bitmap(bmd);

                    }

          }

}

The error I'm getting:

ArgumentError: Error #2015: Invalid BitmapData.

at flash.display::BitmapData/ctor()

at flash.display::BitmapData()

Something I noticed is when reducing the bitmap size flash will produce more bitmaps before throwing the error.

When multiplying:

Bitmaps Created before error was thrown x each BitampData size (example BitmapData size: 500x500), the overall amount of pixels generated before the error was thrown is very similar: more than 400000000.

Amount of bitmaps generated before the error was thrown, in bulks of 100:

1600: 500x500

2600: 400x400

4800: 300x300

Creating in smaller bulks will lead to more accurate numbers, but I think I'm onto something here - deliberate flash limit?

This topic is closed to new replies. Start a new post to keep the conversation going.
Correct answer kglad

more likely it's your ram limit.

16 replies

kglad
Community Expert
kgladCommunity ExpertCorrect answer
Community Expert
December 6, 2013

more likely it's your ram limit.

Known Participant
December 6, 2013

Far from it, it takes 1.8gb before the error is thrown, while I have 8gb.

kglad
Community Expert
Community Expert
December 6, 2013

do you have a 64 bit os and flash cc?

if not that's a ram limit.