Lua garbage collection fails to remove unused data

i attached a mod that reproduces this issue within 10 seconds bloat.zip

the bloated memory size remains even after a reloadlua. you'll see it balloon to 256MB+ very quickly, even though the mod saves barely any data.

At that memory size you also start getting lagspikes from the garbage collection, even when you clear the contents of the script

if you load a save then, the garbage gets transferred into inactive memory, but the garbage collection still scans it every time at the cost of a lagspike

This is just a demo mod to make it easy to reproduce the problem.

The reality of it is that when i enable every mod i made, the memory balloons to similar levels (256MB) after half an hour of playing.

Please note that the garbage is not always assigned to the correct mod in the F10 profiler

Edited by Ownly Me