timer.lua memory leak

Hi,

I created an issue about this on github on Nov 14 2022 and even wrote to Vlad on 21 Nov 2022 and still got no response so after more than a year of using custom timer lib: can we get a fix for that built it?

I fixed it with adding this loop inside “if not inRunlist then”:

local pausedTimers = timer._pausedTimers
for i,v in ipairs( pausedTimers ) do
	if v == entry then
		entry._removed = true
		tRemove( pausedTimers, i )
		break
	end
end
1 Like

You’re right. I never realized earlier, but this is also happening in my code. I don’t use timer.pause very much, but this is definitely happening with paused timers like you mentioned.

If the timer is paused and you call timer.cancel(timerId), then it doesn’t work correctly and the timer sticks around in the timer._pausedTimers table.

It’s not enough to cause a memory issue in my case, but it does happen.

Edit: Since I only have this case with 1 timer, as a workaround, I do timer.resume(id) before calling timer.cancel(id). So it’s never in a paused state before being cancelled.

I guess independent libraries sometimes get overlooked. Can you create a pull request with the proposed change and ping @vlads on GitHub?

1 Like

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.