Probably a dumb question, but do I have to create some sort of manual cleanup system after CurrentTween.Completed:Wait()
or will it automatically get garbage collected after the function?
1 Like
The local variable for the tween will automatically be garbage collected after the function has ended because the variable is not needed anymore.
You can read about it here:
Variant RBXScriptSignal:Wait ( )
Yields the current thread until this signal is fired. Returns what was fired to the signal.
… so there simply isn’t any mechanism for cleaning up Event:Wait() calls since they don’t create any Connection objects like Connect does.
If you want to know what can create memory leaks, check out these posts, especially the last one:
This article is meant to teach you how to prevent memory leaks and how the Roblox lua garbage collector works.
What is garbage collection?
Garbage collection, for those who are new to the term, is the process that a lot of languages such as JavaScript, python, and lua use to clean up memory. When values are no longer being used, they get garbage collected thus freeing up any memory they used.
What are memory leaks?
Memory leaks may sound like something scary. It might sound like it means infor…
Preface
I’ve seen several experienced developers not knowing this, or not having a full understanding of what’s going on, so I thought I’d write a dedicated post on the issue of accidentally leaking Instances (so that they are not GCed even when there are no references to them) through lingering event connections.
What circumstances cause a leak
do -- All good, this part will be GCed just fine
local p = Instance.new('Part')
p.Touched:connect(function() print("Touched") end)
end
do -- O…