Closed VP-0822 closed 1 year ago
@VP-0822 maybe you can take one of the simple examples provided with the library, for example dedicatedWorker.js
, remove the pool..terminate()
, and monitor how that behaves on your machine, and see what memory it uses for process
vs thread
.
It's hard to tell why the OOM error occurs without actually debugging it. An important difference with worker_threads is that they share memory with the main process, where as a child_process has it's own memory. Suppose both your main process and your worker use 6GB of memory. That will work fine with child_process when you have --max-old-space-size=8192
, but will be a problem if you use worker threads since the total memory is 12 GB, above the max of 8GB.
The following node.js issue may be relevant too since I see you're configuring both --max-old-space-size=8192
and "maxOldGenerationSizeMb":768
: https://github.com/nodejs/node/issues/43991.
@josdejong Thanks for the hint. I raised the issue with the library which is throwing this error and they might fix it soon :)
👍
Switching workerpool from child_process to worker thread leads to OOM error. Currently, there is only one worker configured and only one task in the queue. After a worker has initialized, any DB connection-related activity (createConnection, exec, or even rollback) is performed in the main thread, the main node process crashes with an error,
workerpool options are as below,
{"minWorkers":1,"maxWorkers":1,"workerType":"thread","workerThreadOpts":{"resourceLimits":{"maxOldGenerationSizeMb":768}}
The memory usage of main node process during this activity is as below,
--max-old-space-size=8192
for the main node process?Thanks