That's a great hint, thank you!

I tried to do so, but bumped into a problem: I need to pass FS from the old 
module to the new one.
I'm using the most basic default MEMFS.

Any idea how to do it?

Or maybe I should recursively walk and copy files? That's not the most elegant 
solution, but should work.

Kind regards,
Ilya Kantor

> On 9 Feb 2023, at 20:30, 'Sam Clegg' via emscripten-discuss 
> <emscripten-discuss@googlegroups.com> wrote:
> 
> 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 
> <mailto: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 
>> <mailto: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 
> <mailto: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
>  
> <https://groups.google.com/d/msgid/emscripten-discuss/CAL_va28RpzVOUzTAr3zO5bX%2BQWTq%3DdMn08Xwc2y9odMFZKmw-g%40mail.gmail.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/D9B1D151-C606-4E89-AC79-823E58B61BA0%40gmail.com.

Reply via email to