Game starts lagging after server becomes a few hours old

I don’t know if it’s a memory leak, as I’ve checked over all my scripts for anything that might cause a memory leak. My game begins to lag more and more after every round.

I screenshotted the memory stats in the developer console if it will help.

New server:

Few-hour-old server:

Is there something I don’t know about that’s causing this lag? Should I review my scripts again?

1 Like

Do you use any form of looping?

while wait() do
while true do
repeat until ___

If you continuously use any of these methods or other form of methods that include looping, that can cause your game to continue a form of looping, and never stop looping until the server is closed.

Yes, you should view your scripts again.
This problem is a result of a number of possible issues you might have which I will list here:

  1. You may have a virus in your scripts or plugins that constantly instance things and cause your game to overflow with garbage.
  2. You may have inefficient code which you need to optimize, such as
while true do
end
-- or 
while wait() do
end
  1. You could have instanced a part over and over again without removing the item. For this, I suggest using the debris service to take care of parts that are useful for a determined amount of time.

Try seeing if you can diagnose these issues. Hope this helps!