Memory leak progressively breaks tag system

I found the final issue causing the last memory leak but here is what I changed thanks to everybody advice.

Firstly, I added this to disconnect any prior connections that used memory, before setting a new connection. I also removed the second call for this function causing a second creation of a connection, thanks @OniiSamaUwU

if RunServiceConnection then -- If there is a connection we disconnect it & set it to nil
		RunServiceConnection:Disconnect()
		RunServiceConnection = nil
	end

Adding this helped a ton but there was still a memory-leak somewhere. I discovered that inside another function I was setting the

RunServiceConnection = nil

Which caused the variable to be “nil” but the connection was still running. So it wasn’t being disconnected just set to nil and kind of forgotten in memory.

I tested the system for about 5-6 mins of continued tagging and memory stayed the same!
Thanks to everybody who contributed with tips and part solutions. Really appreciate it!
Really hope my case can be helpful for someone else with a similar memory leak caused by connections.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.