Where does an element go if it was created but not integrated anywhere?

For example, we have created a new part

local Part = Instance.new("Part")

And we don’t do anything else with this part.

Its parent is nil, but nevertheless it is created, won’t it somehow slow down the server or affect memory? What will happen to her? Will it be automatically erased?

2 Likes

Yes they still take up memory.

Edit to be more useful: If they leave the scope/have no reference to them at all such as any upvalues, the garbage collector will remove it from memory after some time

2 Likes

It appears that the instances do take memory, but a single one alone does not make too much of a difference. I’m not yet sure if they delete on their own

1 Like

wwwww
Thank you for your answers!

It will continue to exist in memory, and will never get removed from memory. Its not a good idea to be leaving parts unparented like this, because the parts need to be :Destroy()ed to free up memory.

This is a case of what is called a memory leak. Memory leaks happen when some memory is tied up because of an instance, and this instance is not traceable or untracked, and won’t be freed automatically (Instances like Parts are prime examples! Unless you explicitly call :Destroy(), it won’t be garbage collected).

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.