First: local Part = workspace.Part
Let’s say that Part gets destroy in the game and the variable Part is never used through out the code. Will that part get GarbageCollected? Or will it stay there. Cuz I ain’t an industry of NIL to set it to each variable I don’t use… (Sorry for the last sentence)
Second:
if I have a function that is like:
function CollectMe()
local Part = workspace.Part
local Number = 5
while wait(1) do
print(Part.Name)
Number = Number - 1
if Number <= 0 then
break
end
end
end
CollectMe()
While the variable referencing the part is in scope or will enter a scope in the future (as an upvalue for example), it won’t be collected. First scenario is collected, second scenario is collected too after the loop breaks.
I am very worry about the second option because I used OOP in my code and idk if the stuff inside of it, which all is local will get GarbageCollected I never set them to nil that’s why I ask.
Last question and sorry for interrupt you again. What about a function that is in the _G Global Value? Let’s say the Second Option is in a _G variable. Will it get GarbageCollected as well? Cuz I heard rumors that some stuff don’t get collected in _G.