Performance problem due to Lua memory on older device

Hi Folks,

This is my situation:

  1. iPhone 3GS on iOS 5
    lua memory on start is about 2.2MB due to large number of UI elements
    texture memory is about 8MB and major sprite sheets are loaded / unloaded between scenes
    at least 10 scenes with storyboard
    bitmap font

i see no problem with performance using profiler but performance on device sucks. I can see that FPS is jumping from 10 to 60 all the time (due to GC ?)

  1. iPodTouch 4 on iOS 5
    lua memory 2.2MB
    texture memory about 30MB

works great

  1. iPad 2 on iOS 5 (same as iPodTouch) works great also.

My assumption is that Lua memory is filled with not-needed-right-now objects and that is way it works like … its working bad :slight_smile:

Tom [import]uid: 111283 topic_id: 26199 reply_id: 326199[/import]

Those memory number don’t seem like they should cause a problem for an iPhone 3GS.

I would guess that the 3GS just doesn’t have the processor power to keep up with what you are trying to do. Do you use any enterFrame functions? If yes, that’s where I would start looking to see if you can optimize or remove some of the code. [import]uid: 67839 topic_id: 26199 reply_id: 106219[/import]

Thanks,

This is the most heavy part, from 5 to 30 objects in enter frame in dynamic array of objects.

Based on Profiler this is self:translate( 0, currentGameSpeed) the heavy part. But I dont think this is the problem because app i hacking from time to time, not in the moment when objects are created / removed.

[code]


local function diceSelfSmall(self)

if(self.ready == true) then
minimizeDiceSelf(self)
end
end

– move dice
local function moveDice(self)

– if dice is not ready
if(self.ready == false) then
return 1
end

–move of the dice
self:translate( 0, currentGameSpeed)

local where = height

– end of the red dice
if(self.typID == 13)then

– red dice until end,
– normal
where = where * currentGameRedLine

– end of the bomb dice
if(self.y > where - GameDiceSize2) then

– Play sound when bomb dice reach the end
playSound(“tap10”)


if(options.vibrate == true)then
system.vibrate()
end

self:diceSelfSmall()
self.ready = false
end

else

– end of the normal dice
if(self.y > where - GameDiceSize2) then

– Play sound when normal dice reach the end
playSound(“tap02”)

self:diceSelfSmall()
self.ready = false
end
end
end


– ENTER FRAME ------------------

–draw all the dices here
for key, val in pairs( listOfDice ) do
val:moveDice()
end

[/code] [import]uid: 111283 topic_id: 26199 reply_id: 106257[/import]

Nothing jumps out in that code. Are all of the variables locals and not globals?

If you can’t find a pattern to what is happening in the app when the FPS drops, then you may have to just resort to trial and error debugging methods. For example, what happens on the 3GS if you comment out the code to play sounds and vibrate the device? If the FPS still drops, looks for others things to comment out.

[import]uid: 67839 topic_id: 26199 reply_id: 106308[/import]

Any issues known on 3GS with iOS 5.1 ?

I found when i limit Lua memory to 1.2 MB mainly due to not using bitmap font and change it to newText with some tweaks like custom embossing and wordwrapping it starting to work just fine. Basically i limit sprite objects for about 75% due to this change.

I mean there are scenes where a lot text is displayed but performance drop was on completely different scenes without text.

I also found when i exchange only part of text object the threshold was just between 2 MB.

So maybe there is some kind of threshold, over which lower device can have performance problems.

I also found that running GC with slight delay helps in this case a lot (like 1-20 ms).

Regards,
Tom [import]uid: 111283 topic_id: 26199 reply_id: 106311[/import]