Broad help on fixing memory issues

I've nearly finished working on my open-world golf game, which is exciting. It generally works fine, but I get some framerate drops every now and then. Not related to any specific actions or moments that I can easily tell. Just generally while walking around.

When I open the 'device info' window on the simulator, the 'game' is most commonly using between 70-95% of the device CPU. Garbage Collection fluctuates between 10-30%.

This is my first time making a game for a device where I actually need to consider memory restrictions. Previously I've just used Gamemaker or Unity to make little things where it's no big deal, so the whole world of caring about memory efficiency, leaks, profiling, etc. is entirely foreign to me.

So this is a broad call for any suggestions or tips or links to guides on how to broadly just refactor my Playdate lua code to be more efficient and... better? Like common mistakes beginners like me make or don't know to look out for, or a guide anyone has written on Playdate coding efficiency generally.

I think the game should be fine without me doing any of this (it runs generally fine on my own device at least). But would love it if I could clean it up a bit and fix these framerate drops.

Apologies for the broad request, but if anyone has any general leads to good resources I'd appreciate it!

This document has helped me get performance under control in my (Lua) game:

Lua is foreign to me so some of these tips were not things I'd have thought about, coming from a C/C++ world.

1 Like

Amazing, thank you so much! This looks exactly like what I need.

1 Like

Here's a method of tracking memory usage which should allow you to reduce garbage collection.


Sorry for the slow reply. Been travelling. This looks super useful and definitely something I'll play around with, thank you!!

1 Like