Left over threads staying inside of LuauHeap

Hello!

I’ve been playing around with the LuauHeap viewer in the dev console and I noticed that my settings menu even after being closed would make the number of thread go up by about 7.

But in my code, upon closing the gui, I clear and disconnect everything to prevent this from happening. Is this something normal that will just go away after a while or is this an issue in my code?.

1 Like

It takes some time for the garbage collector to clear it.
Create another snaphot after waiting for a minute and see if the thread count decreased.

Very strange… it didn’t clear these out after waiting for 5 minutes but I’ve boiled it down to the following:
button.MouseEnter:Connect(function() end)

The thread seems to get created the first time the event fires and only goes away when the connection is disconnected. Its not only this specific event but all events in general.

I’ve read on another post that this is intended as every connection gets their own thread created.

This is how all signal connections work in Roblox. They are only garbage collected when the connection is disconnected. A clean way to handle the cleanup of connections, as well as signals if you create them is through Maids.

I was also wondering about re-assigning variables in something like Heartbeat etc. My scripts that employ these connections cause high fluctuation in memory usage due to assigning new values to variables and doing other tasks. Is there a specific way that can reduce this?

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