Skip to content

Commit

Permalink
test: fix calculations in test-worker-resource-limits
Browse files Browse the repository at this point in the history
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: #42702
Refs: #35711
Reviewed-By: Chengzhong Wu <legendecas@gmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Tobias Nießen <tniessen@tnie.de>
Reviewed-By: James M Snell <jasnell@gmail.com>
  • Loading branch information
joyeecheung authored and targos committed Apr 28, 2022
1 parent 6bd2420 commit d311916
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions test/parallel/test-worker-resource-limits.js
Original file line number Diff line number Diff line change
Expand Up @@ -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()) {
Expand Down

0 comments on commit d311916

Please sign in to comment.