mirror of
https://github.com/nodejs/node.git
synced 2025-05-07 17:32:22 +00:00

It transpires that the extra bookkeeping in debug builds sometimes makes the increase in RSS go _just_ over the 5 MB limit, by fewer than 100 kB. Double the limit so we hopefully don't run into it any time again soon. The memory leak it tests for was one where RSS grew by hundreds of megabytes over the lifetime of the test; 5 vs. 10 MB is insignificant. Fixes: https://github.com/nodejs/node/issues/21076 PR-URL: https://github.com/nodejs/node/pull/21080 Refs: https://github.com/nodejs/node/issues/21076 Reviewed-By: Tobias Nießen <tniessen@tnie.de> Reviewed-By: Rich Trott <rtrott@gmail.com> Reviewed-By: Anatoli Papirovski <apapirovski@mac.com> Reviewed-By: Сковорода Никита Андреевич <chalkerx@gmail.com> Reviewed-By: Yuta Hiroto <hello@hiroppy.me> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Tiancheng "Timothy" Gu <timothygu99@gmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
27 lines
780 B
JavaScript
27 lines
780 B
JavaScript
// Flags: --expose-gc --noconcurrent_recompilation
|
|
'use strict';
|
|
|
|
const common = require('../common');
|
|
if (!common.hasCrypto)
|
|
common.skip('missing crypto');
|
|
|
|
const assert = require('assert');
|
|
const crypto = require('crypto');
|
|
|
|
const before = process.memoryUsage().rss;
|
|
{
|
|
const dh = crypto.createDiffieHellman(common.hasFipsCrypto ? 1024 : 256);
|
|
const publicKey = dh.generateKeys();
|
|
const privateKey = dh.getPrivateKey();
|
|
for (let i = 0; i < 5e4; i += 1) {
|
|
dh.setPublicKey(publicKey);
|
|
dh.setPrivateKey(privateKey);
|
|
}
|
|
}
|
|
global.gc();
|
|
const after = process.memoryUsage().rss;
|
|
|
|
// RSS should stay the same, ceteris paribus, but allow for
|
|
// some slop because V8 mallocs memory during execution.
|
|
assert(after - before < 10 << 20, `before=${before} after=${after}`);
|