Performance problem

Thank you for all the suggestions! I’m making a physics based puzzle game. When debugging, I stopped the game after every level, verifying that I’m left with a blank screen to ensure all objects including the background are removed.

That’s an interesting question, I don’t know whether it is texture memory or Lua memory. I had a look through the memory leak module I’m using and it obtains memory usage as follows:

currentMemoryUsage = collectgarbage(“count”)

I’m also a bit surprised, that the game will slow down on in the simulator on my development machine (which is a lot more powerful than any mobile device). Is there some sort of a threshold when a game gets throttled?

collectgarbage(“count”) returns the memory being used by Lua. This is for tables, strings, etc. It’s usually a value in the 100,000’s of bytes order and for some apps, it might climb to a megabyte or two. Generally speaking Lua memory is less than a single image loaded as a background (texture memory). Texture memory is the memory used by your graphics.  The API to get that is:

system.getInfo(“textureMemoryUsed”)  (https://docs.coronalabs.com/api/library/system/getInfo.html#texturememoryused)

This returns the amount of memory in bytes used by graphics and images. Divide it by (1024*1024) to convert it to Megabytes which is a more useful value to look at.  FWIW, collectgarbage(“count”) returns the memory in “Kbytes”. If you want to see that value on the same scale as your texture memory, divide by 1024, though honestly, kbytes is a good scale for that since you’re generally dealing with several hundred kbytes of Lua memory. Most people don’t want to deal with 7+ digits of for texture memory, which is why I recommend converting to MegaBytes first.

Anyway, if you’re not looking at texture memory, that would be a great place to start. Your device (and simulator) are rarely going to run low on memory due to Lua memory usage, texture memory usage is where you’re going to start pushing your device’s limits. You might find on some devices you might only have 50mb of memory available to you. Modern devices could get you a few hundred megabytes of memory to use.

Finally, check to make sure to check your audio. There isn’t a way to measure how much memory audio is taking up, but it can be a sizable drain too.

Rob

Thanks Rob,

Really appreciate the in-depth reply. I was not aware of the texture memory. I test for both now every second:

  • Lua memory: depends on game level, but average is at 660kb, with fluctuations up and down in the 0.5% range as the level gets played

  • Texture memory: between 5.0 and 6.5mb (again depending on game level), with no fluctuations whatsoever as level gets played (unless an object gets removed, then it goes down accordingly)

I will completely remove all audio next and see if that makes a difference.

Update after a few more days of testing: Removing all audio does not make a difference. Is there anything else I could be missing?

I’m sad to see that it all came down to this but can you comment out all parts of your code and include them one at a time so you can see which part causes the problem?

Hi hmhm,

what exactly is running slow? Have you set the framerate to 60?

I’m not sure that’ll solve the problem, because you aren’t using transitions etc but it’s worth the shot!

Once again thank you for all the replies and ideas!

@ bgmadclown: I’ve done that as far as I could take it (that’s usually my first debugging approach). The game relies heavily on physics and liquidfun; for instance if I un-comment the liquidfun particles, then the game simply won’t be playable and I can’t progress to the stage where it slows down.

@ bramvbilsen: that is correct, it runs at 60fps

Can you send out a build via TestFlight? If so, I can send you my e-mail address through messages. I would like to take a look at what happens in the game.

Thank you for the offer, I will send you an email.