"Too many objects" error when adding dictionary to array

powerArray= {"height" => 1, "gradient" => colorBarLow };[/CODE]

Gives me error Too many objects when I run app in emulator. Later I can add dictionary to the array without errors.

powerArray= 1;[/CODE]

Runs app withour problem. Any idea what is the problem?
  • 1540

    powerArray= {"height" => 1, "gradient" => colorBarLow };[/CODE]

    Gives me error Too many objects when I run app in emulator. Later I can add dictionary to the array without errors.

    powerArray= 1;[/CODE]

    Runs app withour problem. Any idea what is the problem?

    I changed the code to this, which does exactly the same thing. Any idea what was wrong with the original?
    for (var i = 0; i < powerArray.size(); i++) {
    add(i);
    }
  • Ok. Add one more "?" to my confusion. The code initially worked and now it throws the same "Too many objects" error.
  • This sounds like a case where you were close to the max (which I believe is 256) before this, and this bit of code can throw you over the max at times.

    You may need to look at how you do some other things in the code to resolve it.

    For example, I had a case where I was using a two dimension array:
    var data=new[200];
    for(var i=0;i<200;i++) {
    data=new[2];
    }
    [/code]
    I'd run out of objects with this.

    but if I kept it as a one dimensional array with two parts, all worked fine:
    var data=new[400];
    var partA=0;
    var partB=200;
    Then to access the data, instead of data[0] and data[1], I'd use data[partA+i] and data[partB+i]. Making the array 2 dimensional burned up a lot of objects.

    This is just an example, but shows how to get close to the max and how to avoid getting close to max.
  • This sounds like a case where you were close to the max (which I believe is 256) before this, and this bit of code can throw you over the max at times.

    You may need to look at how you do some other things in the code to resolve it.

    For example, I had a case where I was using a two dimension array:
    var data=new[200];
    for(var i=0;i<200;i++) {
    data=new[2];
    }
    [/code]
    I'd run out of objects with this.

    but if I kept it as a one dimensional array with two parts, all worked fine:
    var data=new[400];
    var partA=0;
    var partB=200;
    Then to access the data, instead of data[0] and data[1], I'd use data[partA+i] and data[partB+i]. Making the array 2 dimensional burned up a lot of objects.

    This is just an example, but shows how to get close to the max and how to avoid getting close to max.

    So I figured. I changed it to 2 separate arrays. Strange that there were no previous discussions about this... :)
  • Actually, I learned about this from Travis a while back, but it's been a while since it came up! :0
  • Actually, I learned about this from Travis a while back, but it's been a while since it came up! :0


    Googling for the error didn't get any hits. Which was a big surprise. :)