From: Jérôme Benoit Date: Sun, 26 Nov 2023 10:48:15 +0000 (+0100) Subject: fix: fix worker node event emitter memory leak X-Git-Tag: v3.0.9~2 X-Git-Url: https://git.piment-noir.org/?a=commitdiff_plain;h=9f99eb9b411c296f8e69e758fd2296902be4fca4;p=poolifier.git fix: fix worker node event emitter memory leak Signed-off-by: Jérôme Benoit --- diff --git a/CHANGELOG.md b/CHANGELOG.md index 24762e5f..a9795487 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,6 +11,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Remove all pool events listener at pool destroying. - Remove all worker node events listener at worker node destroying. +- Fix worker node event emitter listeners handling memory leak at pool options runtime change. ## [3.0.8] - 2023-11-25 diff --git a/benchmarks/benchmarks-utils.js b/benchmarks/benchmarks-utils.js index 678b41d7..b7826a0c 100644 --- a/benchmarks/benchmarks-utils.js +++ b/benchmarks/benchmarks-utils.js @@ -81,9 +81,9 @@ const runPoolifierPoolBenchmark = async ( poolSize, { taskExecutions, workerData } ) => { - const pool = buildPoolifierPool(workerType, poolType, poolSize) - const suite = new Benchmark.Suite(name) return await new Promise((resolve, reject) => { + const pool = buildPoolifierPool(workerType, poolType, poolSize) + const suite = new Benchmark.Suite(name) try { for (const workerChoiceStrategy of Object.values( WorkerChoiceStrategies diff --git a/src/pools/abstract-pool.ts b/src/pools/abstract-pool.ts index 43af4f7c..d51970ef 100644 --- a/src/pools/abstract-pool.ts +++ b/src/pools/abstract-pool.ts @@ -594,11 +594,13 @@ export abstract class AbstractPool< this.buildTasksQueueOptions(tasksQueueOptions) this.setTasksQueueSize(this.opts.tasksQueueOptions.size as number) if (this.opts.tasksQueueOptions.taskStealing === true) { + this.unsetTaskStealing() this.setTaskStealing() } else { this.unsetTaskStealing() } if (this.opts.tasksQueueOptions.tasksStealingOnBackPressure === true) { + this.unsetTasksStealingOnBackPressure() this.setTasksStealingOnBackPressure() } else { this.unsetTasksStealingOnBackPressure()