Yes, I think we have to receive the memory in a special way in workers in pthreads+modularize mode. So the goal isn't to support users providing their own memory, but to make things work at all in workers.
If this is useful - and your use case sounds reasonable! - then we should fix this. PR would be welcome. One thought is that perhaps this should be behind a flag, as it will increase code size (the optimizer won't be able to remove it statically), and we prefer to not do that. On Wed, Jun 19, 2019 at 5:58 PM Joshua Minter <[email protected]> wrote: > Module['wasmMemory'] only seems to be supported when USE_PTHREADS (and > MODULARIZE on second look) is enabled. See preamble.js at lines 48 > <https://github.com/emscripten-core/emscripten/blob/7224b7930ec2a6abca332300e247619e1aea1719/src/preamble.js#L48> > and 1136 > <https://github.com/emscripten-core/emscripten/blob/7224b7930ec2a6abca332300e247619e1aea1719/src/preamble.js#L1136> > . > > As for requiring the same size as the wasm module how does that work for > growing memory? Does it need to be the same initial size? > > Our specific use case is that we need to completely reset the module and > rerun and our current solution is to just scrap everything and load it all > again. However, this causes alot of memory issues so we keep the memory > heap around and try to reuse it. I am currently looking into alternative > ways to restart the emscripten module. > > On Thursday, June 20, 2019 at 5:56:33 AM UTC+10, jj wrote: >> >> In asm.js builds defining Module['buffer'] is enough. In wasm builds >> you need to provide both Module['wasmMemory'] and Module['buffer']. >> The use case of providing a precreated memory buffer was strongly >> defined for asm.js, not sure how well we support it currently for >> wasm. One complication there is that the size of the wasm heap is >> pre-defined in the .wasm module file, so when precreating your own >> memory, you will need to create it with the same size that the .wasm >> module expects. (That limitation may be a reason that providing your >> own Module['wasmMemory'] might not work that well out of the box but >> you may need to do some custom hacks to the preamble&postamble) >> > -- > You received this message because you are subscribed to the Google Groups > "emscripten-discuss" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to [email protected]. > To view this discussion on the web visit > https://groups.google.com/d/msgid/emscripten-discuss/44e6fc91-1771-437c-8ebc-eb9c2b9cf146%40googlegroups.com > <https://groups.google.com/d/msgid/emscripten-discuss/44e6fc91-1771-437c-8ebc-eb9c2b9cf146%40googlegroups.com?utm_medium=email&utm_source=footer> > . > For more options, visit https://groups.google.com/d/optout. > -- You received this message because you are subscribed to the Google Groups "emscripten-discuss" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/emscripten-discuss/CAEX4NpQb%2BEmU7eXYUyWgSXaoAQeVx51gbWCJdg5X7cZEcYo%2BYg%40mail.gmail.com. For more options, visit https://groups.google.com/d/optout.
