MSDLF
(Masol)
September 3, 2021, 7:17pm
#1
for example
function createpart(name)
local part = Instance.new("part", game.Workspace)
part.Name = name
-- more code etc etc
return part
end
Does part stay there without getting garbage collected or do I have to insert part into a table and then at the very end set part to nil.
It will get garbage collected if you don’t hold a reference to the part. All references to the part within createpart are lost when it finishes but if any variable points to the return value of createpart then that part will survive until that reference is lost.
MSDLF
(Masol)
September 3, 2021, 8:02pm
#3
it’s weird because memory keeps building up in my game and everything gets destroyed after each round ends. References and tables are set to {} too.
it’s hard to understand cause it goes from 330 to 1200 MB server usage and never comes down
D0RYU
(nici)
September 3, 2021, 8:13pm
#4
function createpart(name)
local part = Instance.new("Part")
part.Name = name
-- more code etc etc
part.Parent = workspace
return part
end
you should set the parent last