Question regarding references to Roblox objects

Hello. Say I were to instantiate an object such as a part. If I were to store a reference to it in a table, and not give the part a parent, would it be destroyed once the table is nullified?

Hello, could you be more descriptive please?

local references = {}
references[1] = Instance.new("Part") -- Instantiate a part and keep a reference of it in the table
references = nil -- nullify the table

Would the part be destroyed once the table has been nullified since it has no parent?

No, it will store the part’s location

It will be destroyed if there are no references to it.
You can test it out: (with ‘View → Performance → PerformanceStats → Memory’ open)

local references = {}
for i=1, 100000 do
	references[i] = Instance.new("Part")
end
references = nil
1 Like