So I have a little problem with memory usage on android (can’t test ios now so not sure about iphone). I’m using tilesheet.drawTiles on every frame. Memory usage goes to ~15 mb, drops to ~13 mb (gc?) then withing 10 seconds it goes again to ~15 mb, drops to 13 and it goes like that forever. Is that normal behavior? I mean everytime it goes down to 13 there is a small hiccup and fps drops to 27-28. Is there any way to avoid those hiccups? Here is what I’m doing on enterframe, I’m drawing around 120-150 objects at the same time:
[CODE]
renderSprite.graphics.clear();
renderArray.splice(0, renderArray.length);
var numChildren:Int = children.length;
var i:Int = 0;
while (i < numChildren)
{
var child:ZSprite = children[i]; //ZSprite contains data on position, matrix, and tile id
if (child.visible)
{
renderArray.push(child.x);
renderArray.push(child.y);
renderArray.push(child.currentFrame); #if neko
child.resetMatrix(); #end
var matrix:Matrix = child.matrix;
renderArray.push(matrix.a);
renderArray.push(matrix.b);
renderArray.push(matrix.c);
renderArray.push(matrix.d);
child.update();
i++;
}
}
tilesheet.drawTiles(renderSprite.graphics, renderArray, SMOOTHING, Tilesheet.TILE_TRANS_2x2);
[/CODE]
Yup, eliminating splice and pushes on every frame fixed this
Android version runs better however there is no performance difference on flash which is kind of weird I guess…but it’s not really an issue. Thanks everyone
Depending on your device, Flash might be running on something much more powerful (and with more RAM) than your Android device. That could account for why it’s a negligible difference in Flash… Or maybe not.