Skip to content

Fix for issues/294 - #295

Open
rbroderi wants to merge 3 commits into
scoder:masterfrom
rbroderi:master
Open

rbroderi wants to merge 3 commits into
scoder:masterfrom
rbroderi:master

Conversation

@rbroderi

Copy link
Copy Markdown

A possible fix for #294 I won't claim to be an amazing c programmer but this fix seems to be where the problem is. I would suggest reviewing this as it was AI assisted. It would be at least a good start as to a fix for #294.

Copilot AI and others added 3 commits September 11, 2026 01:18
Co-authored-by: rbroderi <15883611+rbroderi@users.noreply.github.com>
Co-authored-by: rbroderi <15883611+rbroderi@users.noreply.github.com>
@scoder

scoder commented Sep 11, 2026

Copy link
Copy Markdown
Owner

Thanks. So, from what I understand, the issue is that Lua's garbage collection (in Lua 5.5) can take its time to free unused userdata entries after Lupa marked them as released, and Lupa might end up reusing the slot before it's actually freed.

You resolve that with a freelist that keeps all userdata alive and never frees it, and instead does its own reuse management. Right?

That doesn't seem a bad idea, and it might even have a positive effect on allocation speed. But it does have the downside of keeping all userdata alive, which can become a visible memory leak when memory usage (or, rather, the live object count) changes largely over time.

I think I found a simpler fix in #296

Please test it on your side. I tried to take care that it doesn't introduce memory leaks but I'm not entirely sure that I succeeded.

@rbroderi

Copy link
Copy Markdown
Author

Thanks for the quick look at this. I will check it out. And yes your fix does seem simpler.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants