memory usage and debug.sethook
Posted: Wed Oct 09, 2024 10:28 pm
Hello,
I am writing a game in PICOLOVE hybrid and been trying to reduce per-frame memory allocation to unburden garbage collector. My typical per frame gain is about 37kb, however every couple of seconds it suddenly grows to 100kb. This is not a big issue since GC can handle this without any impact on framerate. I've been trying to narrow it down and find out what exactly is causing these mem alloc bumps. To no avail.
However, I have encountered a strange phenomenon. Once I setup a totally bogus call hook to an empty function
the memory allocation suddenly has no bumps and gets back to steady 37kb per frame.
I would like to know if anyone encountered this as well, what is the reason for this behavior and is it good to ship my game with such hook.
I am writing a game in PICOLOVE hybrid and been trying to reduce per-frame memory allocation to unburden garbage collector. My typical per frame gain is about 37kb, however every couple of seconds it suddenly grows to 100kb. This is not a big issue since GC can handle this without any impact on framerate. I've been trying to narrow it down and find out what exactly is causing these mem alloc bumps. To no avail.
However, I have encountered a strange phenomenon. Once I setup a totally bogus call hook to an empty function
Code: Select all
local function count_calls()
end
debug.sethook(count_calls, "c")
I would like to know if anyone encountered this as well, what is the reason for this behavior and is it good to ship my game with such hook.