Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
1

Does not NILing a table cause data to stack up?

Asked by 5 years ago

I've heard numerous stories about how data leaks could ruin performance in games, and I suspect a cause of this would be not niling tables after theyre used?

local function makeTbl()
    local tbl = {1, 2, 3}
end
for i = 1, 100 do
    makeTbl()
    wait(0.1)
end

Is this an example of a data leak?

1 answer

Log in to vote
1
Answered by 5 years ago
Edited 5 years ago

No. There are no references (it's not stored in a variable or used for anything) so the GC happily gobbles it up. That's no data leak and it won't cause any performance issues.

Anything stored in a variable can't be GC'd.

Leaks are usually the most severe when they're parts that have been destroyed. Just make sure you don't keep them around after destroying them. Keep them local to a function or set the variable to something else.

Ad

Answer this question