What is the maximum amount memory Adobe AIR can utilize?
Asked Answered
L

4

12

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.

Laughing answered 1/7, 2011 at 13:0 Comment(3)
Sorry, was away for vacation. Anyways, you're probably going about it wrong, design wise. What would you need that huge a map? And if you really need it, implement it as a sparse map (with only point with actual content allocated), instead of a full 500 million point map.Metzgar
Hi jpop, My actual issue was generating the map data, not rendering the actual graphics. I've managed to get over the initial problems of object sizes by doing staggered generation. Still not quite as fast as i'd like but hey :PLaughing
I don't think there's any hard limit in AIR - the OS decides when this error happens. But the other answers are true as well - you should find a way to generate or acquire data when you need it, not try to hold everything in memory at once.Sequester
O
2

As of Windows 7, and AIR 3.3 Adobe AIR apps are limited to around 1GB memory allocation. This will change once Adobe AIR becomes 64-bit. Adobe plans to do 2 different rewrites of the platform. The first rewrite will take place by the end of 2012. This rewrite will add multithreading to the Flash, AIR runtimes. This first rewrite probably will not fix the existing memory allocation issues and limitations. But the second rewrite will for sure which is coming in 2013 codenamed "Next". This rewrite is the "ActionScript 4.0" which includes 64-bit runtime, memory allocation enhancements, programming language enhancements, new compiler, and a huge improvement in performance. Until then do not try to allocate more than 900MB of RAM at the risk of the app simple crashing without warning.

Omnidirectional answered 23/5, 2012 at 21:7 Comment(3)
A lot of what you're saying here is interesting - are you able to include some sources in your answer?Quitrent
Adobe has not made an official announcement if they call the ActionScript rewrite 4.0 or not. Check out rivellomultimediaconsulting.com/actionscript-4-revealed for more information regarding how some people are calling it AS4Omnidirectional
Thanks man you saved me a ton of time. Zipping up content when it got above a certain amount of files was crashing on Windows 7 and this appears to be why. Have to do one file at a time. Slower but doesn't crash.Jat
M
0

There's no details provided, but my gut feeling would be that the problem you're having is not lack of memory (which your system has ample) but suboptimal and/or faulty algorhythms. You probably need to rethink the way you generate the maps and also be sure that you're not ending up in an infinite loop somewhere.

If you post more details (possibly in another question) maybe we can be more helpful.

Metzgar answered 4/7, 2011 at 11:12 Comment(3)
Thanks for the reply, Originally i used an Array to store the int values, but then moved on to a ByteArray. Do you think i'm running into a limit of the Array/ByteArray object itself?Laughing
ByteArray is definitely better than a generic Array containing ints, memory/performance wise. What are max dimensions of your map? Are you sure that there's no error in the code which would cause the array to become too big, end up in an infinite loop or something similar?Metzgar
Hi, i updated the main question with my testing details. I'm still not sure on the maximum size of a ByteArray the live docs do not sayLaughing
S
0

Not sure if you're already on this but you can play around with the property System.totalMemory to get a live readout of the amount of memory that flash is using at that moment (all instances of Flash Player/adl, so watch out if you have a browser open with flash content playing)

Link: http://livedocs.adobe.com/flash/9.0/ActionScriptLangRefV3/flash/system/System.html#totalMemory

It may help to display the memory used in a textfield on the screen or add it to a watch list as you debug to find out exactly what classes/methods are eating up all that ram! You could also take readings of the totalMemory and put in breakpoints to stop the program when it hits a certain threshold.

It may also help to only generate a map large enough for what is on the screen, and generate further territory as the player moves in a certain direction and culling the territory that is out of bounds. This form of culling is popular in 3D games to eliminate unseen geometry but will also help for your problem of massive maps and limited memory.

Stipe answered 6/7, 2011 at 16:20 Comment(3)
Thanks for the reply, i've updated the question with my testing setup. There are no other running flash instances. I have a system written that loads only the data necessary for display. However that data has to exist. My map generator is a separate element at the moment.Laughing
This link has a post dealing with a similar issue. As far as I can tell, the standalone flash player has no limitations on the amount of memory it uses. In browser is a different story, but this person seemed to have a similar problem with the flash player. Apparently FP10 in Linux has no limit, but other versions cap out at a certain point. Running your test mine capped out at 900mb, but I still had some room to spare judging by my task list.Stipe
I've run a couple of tests (detailed above) These are all on OSX. I'll run the same tests again on W7 (64) When later tomorrow evening. It does seem like i'm hitting some sort of limit of the ByteArray object, still no luck finding actual adobe documentation on size limits.Laughing
T
0

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.

Terwilliger answered 4/10, 2017 at 12:45 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.