Game slowly get's more laggy the longer the server is active?

So im making a game and I notice when you first join the game there is almost no lag, but as the server stays active it gets more and more laggy. Any idea why and is there any way I can stop it?

2 Likes

Are you creating lots of objects and not removing them?

Make sure to remove stuff as soon as you’re done with them - otherwise it all adds up after a while. You’ll see the same behavior if you make an infinite while loop that makes a part every second.

would there be a easy way to find out if this is happening?

You don’t really give a lot of information on what is happening in your game, are there parts being created a lot?

Edit: also you can use the micro profiler to see what is causing lag (if its framerate you are talking about)

i belive im deleting them, its just I dont want to go through every script in the game to find if im deleting parts.

I would recommend to try using the microprofiler first and then make sure you are deleting the parts in the right way using :Destroy() instead of :remove()

nope never using remove.

Monitor server memory in the f9 console.

What is an unacceptable amount of Server Memory being used? When do those numbers become dangerous for lag/connection?

3 Likes

It sounds like you may have a memory leak, which is when you are creating and/or references objects but you aren’t removing that object (reference). As the others have suggested, I suggest looking at the microprofiler as well as going through your scripts again to see if you can find the cause,Although it may not be directly related to your issue, you can check out this post by the ever-talented @stravant. Stravant basically explains in some detail why certain connections will be garbage collected and others won’t, which may help you further understand memory leaks.

1 Like