Open oshyshko opened 6 days ago
Here is an example branch https://github.com/SimonLSchlee/zig15game/tree/wasm-allocator-test commit https://github.com/SimonLSchlee/zig15game/commit/1716c998db0a118c832da17e1d8eb86b47b432b2 for how you can get allocators to work, I am not sure if this is the best or only way.
Once you have built the wasm application you need to host it with the headers seen in the server.go
help script (run via go run server.go
see the commit above), this is a convenience script for running a webserver with the right headers for debugging locally from this example https://github.com/permutationlock/zig_emscripten_threads
You then should see the INFO logs for the number if you visit localhost:8083 and open your console.
Looks like there is a problem with emscripten https://github.com/ziglang/zig/issues/19072
Switching std.heap.c_allocator
made it work.
Applying changes from 1716c99 didn't work. The error.OutOfMemory
error changed to `RuntimeError: index out of bounds.
I think you are running different code, because compiling commit 1716c99 with zig 0.13.0 works for me, so I think there may be another issue, either that or the error appears when making more / bigger allocations.
But if using std.heap.c_allocator
works, I think that is good enough as a work around until zig or emscripten fixes something?
I am getting
error.OutOfMemory
when using any allocators with your setup.Please, confirm if you also have this problem, and if you have a workaround.
Here's a minimal
main.zig
:or
Environment: