Roblox's Lua VM Garbage Collection

Does Roblox’s Lua VM automatically garbage collect in game and if so how often?

Yes

Undefined, but this shouldn’t matter anyway. Is there a particular reason why you think you have to know?

1 Like

I am working on an library for personal use, which requires tables to be removed upon completion, in most situations these wont be being removed and added in a short period of time, but there are a few times in which it is a requirement. I also am aiming to use as little server memory as required, and creating data adding it to the stack and then removing it will use a fair amount of memory/

If you remove all references to the table, it will be garbage collected

But how often though?

GC is shown in the micro profiler. Are you using a weak table?

It is undefined, so there is no way to tell and any frequency you may observe right now through the microprofiler might change again in the future since it is undefined (i.e. its behaviour may arbitrarily change without notice so you shouldn’t rely on it being a particular frequency). I highly doubt this actually affects your work though, and if you think it does please post a short example of why you think garbage collector speed might affect anything. Typically you shouldn’t be hitting server memory limits anyway.

2 Likes

I’d sometimes like to be able to free memory as well so that when I know I’m not going to be using something I can prevent a little overhead by telling the GC I’m done. But then again, sometimes I can’t decide if I like C or Lua more…

To sum it up, just as @buildthomas said, my wishes are in vain and this is not possible in RBXLua.