Hi Ilya, Emscripten doesn't have any way to do that today (at least not that I know of).
Your best bet is probably to use `-sMODULARIZE` and then construct a new instance for each time you want to call `main`. i.e `new MyModule()` each time. cheers, sam On Thu, Feb 9, 2023 at 11:18 AM Ilya Kantor <ilia...@gmail.com> wrote: > Hello, > > I use Emscripten to compile a CLI application, and then run its _main many > times. > > The problem is that it expects every call to be "from the scratch", with > uninitialized data structures. > > Right now, e.g. a file has `struct my_type s`, and initializes it on the > first run, then it survives till the second run and spoils it. > > How to re-init WASM, to clear memory for new runs (start afresh) while > keeping FS untouched? > > -- > 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 emscripten-discuss+unsubscr...@googlegroups.com. > To view this discussion on the web visit > https://groups.google.com/d/msgid/emscripten-discuss/140af2b7-874c-4308-8563-044e066fd89fn%40googlegroups.com > <https://groups.google.com/d/msgid/emscripten-discuss/140af2b7-874c-4308-8563-044e066fd89fn%40googlegroups.com?utm_medium=email&utm_source=footer> > . > -- 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 emscripten-discuss+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/emscripten-discuss/CAL_va28RpzVOUzTAr3zO5bX%2BQWTq%3DdMn08Xwc2y9odMFZKmw-g%40mail.gmail.com.