views:

168

answers:

3

I'm looking into converting a flash app I have into Javascript but was told that it probably wouldn't be possible due to the number of objects I would have to have on the go.

Can anyone tell me if this is true and, if it is, what the limits are?

TIA,

Urf

+2  A: 

This post shows that you can allocate at least 20mb of memory in FF http://blog.votanweb.com/2007/2/24/javascript_memory_limit

There is definately a limit though, but I doubt you'll meet the limit on memory, it is more likely that your performance will be too bad if you are converting a very dynamic flash app.

Per Stilling
Thanks Per. The link was very useful for testing the capabilities of the browsers I need to use.
Urf
+3  A: 

Flash is very efficient at moving objects around since thats its primary function. Using Javascript to move objects around in HTML is going to way, way slower. Never-the-less quite amazing things can be acheived with Javascript.

See Lemmings

AnthonyWJones
Thanks for the answer. It was a close call on the assignment of the green tick but I had to go with Per as the script in his link was very useful for testing each of the browsers I need to work with. Very impressed with the JS version of Lemmings though. That's getting bookmarked!
Urf
+1  A: 

An improved version of the script at link text. This is faster since it uses join, and lets the browser have some time to update the page evey now and then.

function allocate_mem() {
    var mega=[];
    // Strings are stored as UTF-16 = 2 bytes per character.
    // Below a 1Mibi byte string is created
    for(var i=0; i<65536; i++){
        mega.push('12345678')
    }
    mega=mega.join("");

    var x=document.getElementById("max_mem");

    var size=0;
    var large=[];
    function allocate( ) {
        ++size;
        //if (size>400) {alert(large.join("").length/1048576); return; }
        large.push("."+mega.slice(0));
            x.innerHTML = "max memory = " + size + " MB";
        setTimeout(allocate, size %10 ? 0: 200);
    }

    allocate();

}
some