Game's client memory increases with time

I want people to have a smooth/lag free experience in my Tower of hell based game

The client memory in my game keeps increasing with time and its causing players to lag
After being in the server for an hour, the client memory keeps building up and reaches to about 1000MB. People have reported to have lower fps/they were lagging.
One of the people sent me a screenshot of they client memory after staying in the server for more than an hour, he reached 1000MB of client memory
image

So i would like some advice on how to prevent this from happening

I have taken measures to prevent this such as using :Disconnect() on connections like kill bricks touch when the kill bricks are destroyed, as well as refrained from using while true do and using RunService.RenderStepped for loops instead.
But something still seems to not working quite right and the client memory still rises and causes lag for the players
I’ve looked into my local scripts many times for any possible cause of the memory increase but i can’t seem to find anything that maybe be causing it.

There are Conveyors, Fading Parts, Kill Parts, Moving Parts, Slippery Parts, Local Parts and Spinning Parts in the game at the moment which are made local/work from local scripts
and Buttons and Height bar, etc

Thanks in advance.

Have you tried using a maid to cleanup all of your connections after calling them? You might have missed some.

May i ask what’s a “maid cleanup”?

It practically helps you with disconnecting functions etc…

By the way, sorry for the off-topic but Im on mobile currently so excuse long wait time for me to reply.

1 Like

In the developer console, go to Memory. Make sure “Client” is selected. Scroll down to “PlaceScriptMemory”. It should show the cause of the lag(as it gives the names of the scripts), which should make it easier to find the solution. You could also try checking PlaceMemory>Script, but this just gives the overall memory usage of scripts if I’m correct.

1 Like

Thanks for the info and sorry for the late reply, i’m not using the maid module to connect/disconnect functions but this seems useful, should i use this to connect and disconnects functions?

Currently it only says its using about 5 Mb of the memory, don’t think that’s a lot and if it ever rises up i won’t be able to tell exactly which script is is causing the lag because it gives the overall memory usage of scripts

Although the Place memory keeps rising up

Underneath PlaceScriptMemory it shows what scripts are using what amount of memory

1 Like

It stays at about 3-5 MB of memory in the scripts tab, which is normal i believe
image

I meant literally underneath PlaceScriptMemory. It shows which scripts individually, by name, are using what amount of memory.


(As you can see, a localscript named “ClientWeaponFXHandler” is using 0.063 megabytes of memory)

I was able to solve this issue by using Maid and cleaning up after every round.
Maids are pretty amazing for managing state.