• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1// Flags: --expose-gc --noconcurrent_recompilation
2'use strict';
3
4const common = require('../common');
5if (!common.hasCrypto)
6  common.skip('missing crypto');
7if (process.config.variables.asan)
8  common.skip('ASAN messes with memory measurements');
9
10const assert = require('assert');
11const crypto = require('crypto');
12
13const before = process.memoryUsage.rss();
14{
15  const dh = crypto.createDiffieHellman(common.hasFipsCrypto ? 1024 : 256);
16  const publicKey = dh.generateKeys();
17  const privateKey = dh.getPrivateKey();
18  for (let i = 0; i < 5e4; i += 1) {
19    dh.setPublicKey(publicKey);
20    dh.setPrivateKey(privateKey);
21  }
22}
23global.gc();
24const after = process.memoryUsage.rss();
25
26// RSS should stay the same, ceteris paribus, but allow for
27// some slop because V8 mallocs memory during execution.
28assert(after - before < 10 << 20, `before=${before} after=${after}`);
29