-
-
Notifications
You must be signed in to change notification settings - Fork 36
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Memory error with repeated calls #109
Comments
According to the Lua manual:
Running I am not sure whether this library should call |
This helps me move forward, thank you! I do think this is something to fix. When using the API directly, it makes sense to manage the stack because that's how you communicate with lua:
However in wasmoon, not only does // i already have my result, so no incentive to access stack
const result = await lua.doString(`return ${a} + ${b};`);
// stackResult is always undefined. This is just busy-work
const stackResult = lua.global.pop(); |
@aekobear thanks for the suggestion, I think it does make sense for wasmoon to pop the values returned, I can't think on a use case for returning the value and it continue on the stack |
@tims-bsquare do you have any opinion on this? |
I think the lua_xmove is the memory leak in callByteCode. I can't remember why it's that way though. I have a suspicion something about returning a function from doString and calling it later but in theory a reference to that should continue to exist through lua_ref. Could try and remove it and see if things break? |
I wrote a small script to benchmark wasmoon's runtime overhead with multiple calls. However calling
doString()
more than a few dozen times causes a memory errorThis script should print 1000 random numbers then return. It always works for roughly the first 60, the crashes with:
I tested on
[email protected]
and[email protected]
and got the same resultThe text was updated successfully, but these errors were encountered: