From d311916f376f9ce07cbd93086db4560b59827259 Mon Sep 17 00:00:00 2001 From: Joyee Cheung Date: Tue, 12 Apr 2022 02:35:53 +0800 Subject: [PATCH] test: fix calculations in test-worker-resource-limits MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The heap size limit should be the sum of old generation and young generation size limits, and does not solely depend on the limit of the old generation. PR-URL: https://github.com/nodejs/node/pull/42702 Refs: https://github.com/nodejs/node/issues/35711 Reviewed-By: Chengzhong Wu Reviewed-By: Anna Henningsen Reviewed-By: Tobias Nießen Reviewed-By: James M Snell --- test/parallel/test-worker-resource-limits.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/test/parallel/test-worker-resource-limits.js b/test/parallel/test-worker-resource-limits.js index ffda452f6c6335..f79c31b2a18793 100644 --- a/test/parallel/test-worker-resource-limits.js +++ b/test/parallel/test-worker-resource-limits.js @@ -35,10 +35,10 @@ if (!process.env.HAS_STARTED_WORKER) { assert.deepStrictEqual(resourceLimits, testResourceLimits); const array = []; while (true) { - // Leave 10% wiggle room here, and 20% on debug builds. - const wiggleRoom = common.buildType === 'Release' ? 1.1 : 1.2; const usedMB = v8.getHeapStatistics().used_heap_size / 1024 / 1024; - assert(usedMB < resourceLimits.maxOldGenerationSizeMb * wiggleRoom); + const maxReservedSize = resourceLimits.maxOldGenerationSizeMb + + resourceLimits.maxYoungGenerationSizeMb; + assert(usedMB < maxReservedSize); let seenSpaces = 0; for (const { space_name, space_size } of v8.getHeapSpaceStatistics()) {