Question about connections and memory leaks

I think I have a memory leak in my game, because FPS decreases over time. It’s very subtle though, and it takes about an hour and a half to start taking effect (this is really short though for a real game scenario though when servers are running for way longer than that, so it’s a problem)

I’m not sure where to start, but I have a few questions.

  1. Do connections in StarterCharacterScripts need to be disconnected on death? I figure that they should be automatically disconnected and refreshed again because of respawning. Same thing with StarterGui.

  2. Do tools in the backpack need to have all of their connections disconnected on death?

  3. Say you have a script in a car. If you destroy the car, all those connections in the script should disconnect, right? Even something like a while loop?

  4. Do I have to disconnect connections on players like playerAdded? I figured they should automatically be disconnected.

  5. Where else should I look? Tool connections?

1 Like

When scripts are destroyed, all associated connections and such are garbage collected automatically. And when players respawn and all that, those previous scripts are destroyed, so this would take immediate effect. Unless you have something like ResetOnSpawn turned off on the GUI.

I would look at script activity rates, if you can. If you see something running at something higher than say, 5%, it might be worth investigating that specific script.

By the looks of it, the server isn’t handling memory as efficiently as it could be, causing some memory leaks that’s never taken care of because the server script is never destroyed.

Hope this helps :slight_smile: