What is the maximum amount memory Adobe AIR can utilize?

Viewed 6493

I've been doing some rapid prototyping for a game I'm thinking of building. one of the main things i want to do is map generation for a tile type map. While generating the map i end up using large amounts of ram. I'm building the map as an array of random integers for my test. When i try to generate maps of a large scale flash gives me the out of memory error:

Error: Error #1000: The system is out of memory.

I've already figured i could write to a file instead, to solve that problem. but does anybody know the actual maximum size? I've tried searching around to no avail.

Activity monitor reports that ADL is using around 500MB "real memory" and around 700MB "virtual memory". The System.privateMemory property seems to match the "real memory" value.

as a side note i'm developing in OSX Snow Leopard (64) with 8gb ram

EDIT:

Here the example test i am running

var ba:ByteArray = new ByteArray();
for(var i:uint = 0; i<100000000; i++)
{
    ba.writeInt(int(Math.random()*100));
}

trace("end", ba.length, System.totalMemory);

This example runs fine, afterwards the total memory property reports around 500MB of ram used. Now increasing the target value to 400,000,000 i eventually receive the 'out of memory' error.

note: Testing in Flash CS5.5 with the timeout set to 120 seconds (the test never reaches that time)

EDIT:

i've created a better testing example:

var i:uint = 0;
var loopLength:Number = 500000000; // 500,000,000
var ba:ByteArray = new ByteArray();

for(i=0;i<loopLength;i++){
    try{ba.writeInt(1);}
    catch(e:Error){
        MEM_TI.appendText(e.message);
        break;
    }
}    

ba.position = 0;
MEM_TI.appendText("\nTM: "+System.totalMemory+" FM: "+System.freeMemory+" PM: "+System.privateMemory+" BALENGTH: "+ba.bytesAvailable/4);

When i run this script from a browser, stand-alone debugger or AIR i get roughly the same memory usage readouts (which i know vary anyway). What is constant however is the final length of the byte array:

Browser (Firefox): TM: 540413952 FM: 19116032 PM: 562573312 BALENGTH: 134217728

Stand-alone: TM: 540577792 FM: 1810432 PM: 545361920 BALENGTH: 134217728

AIR (2.6): TM: 5410816 FM: 1159168 PM: 551464960 BALENGTH: 134217728

My testing methods might not be perfect, though i dont know how to do deeper profiling.

4 Answers

I've investigated this issue a bit recently and indeed there seems to be a memory threshold (dependent on the platform and, it seems, especially on the OS) after which an AIR app will become unresponsive / crash. (I didn't manage to get the out-of-memory Error #1000 though). I've opened an Adobe bug here: https://tracker.adobe.com/#/view/AIR-4198476. Hopefully we'll get some more info from Adobe soon.

Related