Why does my game's servers lags a lot/is unplayable when I let servers run for a while (until I reset the servers.)

Why does my game’s servers lags a lot/is unplayable when I let servers run for a while (until I reset the servers). I have lots of active players in my game, and when it lags/is unplayable it badly effects my game a lot. Memory leaks/untracked memory could be a cause but I already optimized all my code to avoid memory leaks. How can I fix this issue?

How can I double check if all code actually avoids any memory leaks? Or could something else be a cause?

Check the dev console and look at where your memory is getting tracked on the server and client.

LuaHeap should be sincerely low (below 100mb), if it cranks up after a period of time without dying down then you have a memory leak on your hands.

Nothing else will cause this unless your game does more frequent actions over time (very noticeable and simple to catch).

1 Like

Lua heap is 84, but others are way higher such as Place memory (550), untracked memory (275). How can avoid these high memories?

Are those the stats for when you join a fresh server or a supposedly laggy server?
What’s the server memory on a laggy server?

But to answer your questions, there’s a lot you can do to bring down the place memory:

  • Reduce the amount of instances when possible
  • Reduce the size of images you’re using (just a single 1024x1024 image could be 7mbs!)
  • Look for any cases where a part, model, or other instance is not getting destroyed when it should

For untracked memory, it’s just that, untracked. It’s a lot harder to scope down where it’s coming from, but typically they’re just non-garbage collected instances or values (like tables). Sometimes it could even come from Roblox core components. You really wont know unless you know everything about your code! (and I literally mean everything).

I have a small map, and there are no lingering parts/models made from script(s) (As I already optimized all scripts to avoid this.) I made a script that counted the amount of parts in workspace and there were thousands for some reason. Im going to double check my small map but that seems very odd.

Also the Place memory is growing in any public server

If your place memory is increasing then you haven’t optimized everything yet. There’s still instances being left around either in workspace or nil, stagnant until removed by your code.