What I’m trying to do is literally what it says, collecting garbage from chat system messages removing them after a while if a certain amount of player messages aren’t sent in the chat. What’s the alternative for this if there is any and why was it deprecated because it does a great job
There isn’t one. You shouldn’t need to be forcing the GC to run.
I use it because the chat system notifications become spammy
Modify the chat system itself to have the desired behavior.
It was never possible to force a garbage collection through collectgarbage()
on Roblox. The only command that worked was "count"
which got how much memory was in use by Lua.
gcinfo()
is the replacement.
collectgarbage() won’t call the garbage collector in Roblox because it only supports one mode: count. Other modes like collectgarbage(“collect”), which runs a full garbage collection cycle, as well as stop, step, setstepmul, setpause, and restart, are not supported. The count mode only provides memory usage information, similar to gcinfo().
Additionally, Roblox handles garbage collection automatically, so developers cannot manually trigger or control it.