I have some code that will overwrite on an as-needed basis for MANY dictionary entries. Is this the correct way to go about this if I want to make sure all memory is released for the entries:
--Script
local module = require(script.ModuleScript)
local done = module.Add()
local myTable = module.Table()
function removeTable()
for i, v in pairs(myTable) do
print(i,v)
end
myTable = module.Table(true)
print("---table removed checking---")
for i, v in pairs(myTable) do
print(i,v)
end
print("---table checking done ---")
end
removeTable()
done = module.Add()
for i,v in pairs (myTable) do
print(i,v)
end
. .
--Module Script
local module = {}
local theTable = {}
function module.Add()
local counter = 0
local temp = ""
while counter < 3 do
counter = counter + 1
temp = tostring(counter)
theTable[temp] = true
end
return (theTable)
end
function module.Table(valueIn)
if valueIn == true then
theTable = {}
end
return (theTable)
end
return module
--[[ Output
1 true
3 true
2 true
---table removed checking---
---table checking done ---
1 true
3 true
2 true
--]]
It looks like it works how I want it to, but I'm still learning and I really don't want to deal with a problem later on.

1 comment
Ok perfect, thank you! I saw lots of info on how to remove individual entries, yet none on releasing an entire table (with A LOT of entries).