Would this cause a memory leak?

I am trying to clean up a table. Because iterating through it is too difficult (see Efficiently iterating through 3D array), I intend on simply setting its variable to nil, see:

local Table = {{{1,2,3},{1,2,3}},{{1,2,3},{1,2,3}},etc.}

Table = nil

Would the garbage collector clean up Table, and all the tables/values stored in it? Or would those values float in memory causing a leak?

TL;DR no

2 Likes

Tables will only cause memory leaks if you reference roblox instances, and the table does not get GCed

Thanks for the help. I wasn’t exactly sure whether the table counted as a reference or not.

It does, but if the table has no more references and the objects in it don’t either, the objects including the table are eligible for GC

1 Like