--
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-disc...@googlegroups.com.
To view this discussion visit https://groups.google.com/d/msgid/emscripten-discuss/7a2ad872-664e-46a1-88b2-b359886d2f30n%40googlegroups.com.
Thank you for the confirmation, Sam.
I fully understand the explanation (that the worker pool is designed never to shrink).
This aligns with my observations. During my testing, I noticed that even when I tried using the PTHREAD_POOL_SIZE and PTHREAD_POOL_SIZE_STRICT options, the number of threads still seemed to grow beyond the specified size during high-frequency input.
As I mentioned, I have already resolved the issue in my application by changing my design to use pthread_cond_wait (to manage a persistent worker and a queue), which avoids creating new threads repeatedly.
However, this leads me to a follow-up theoretical question:
I understand that for standard Web Workers, we are responsible for memory management and must call terminate() to properly release the worker and its resources.
Since Emscripten pthreads are implemented as Web Workers, I started to wonder: is it possible to manually terminate() an 'em-thread' (a worker created by Emscripten) from JavaScript to force the pool to shrink? Or is this a misguided approach that would break Emscripten's internal thread management?
I am curious if this is the wrong way to think about it. For reference, this is the standard JS pattern I am thinking of:
To view this discussion visit https://groups.google.com/d/msgid/emscripten-discuss/10281f01-8017-4bd8-bc6a-81aa761edc39n%40googlegroups.com.