diff options
author | Rich Trott <rtrott@gmail.com> | 2020-08-22 15:50:30 -0700 |
---|---|---|
committer | Rich Trott <rtrott@gmail.com> | 2020-08-25 06:54:24 -0700 |
commit | a8db32a5042782c5426e229f466ba80bf5995c9d (patch) | |
tree | d6398721d65544137b63d4cdc3b594af1c16d730 /test/pummel | |
parent | b93325cb267e4bb55387b2158140542438a3c371 (diff) | |
download | node-new-a8db32a5042782c5426e229f466ba80bf5995c9d.tar.gz |
test: simplify test-vm-memleak
PR-URL: https://github.com/nodejs/node/pull/34881
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Franziska Hinkelmann <franziska.hinkelmann@gmail.com>
Diffstat (limited to 'test/pummel')
-rw-r--r-- | test/pummel/test-vm-memleak.js | 13 |
1 files changed, 5 insertions, 8 deletions
diff --git a/test/pummel/test-vm-memleak.js b/test/pummel/test-vm-memleak.js index 33f2f3d759..a433ab6565 100644 --- a/test/pummel/test-vm-memleak.js +++ b/test/pummel/test-vm-memleak.js @@ -27,7 +27,6 @@ const assert = require('assert'); const vm = require('vm'); const start = Date.now(); -let maxMem = 0; const interval = setInterval(function() { try { @@ -36,10 +35,11 @@ const interval = setInterval(function() { } const rss = process.memoryUsage().rss; - maxMem = Math.max(rss, maxMem); + assert.ok(rss < 64 * 1024 * 1024, + `memory usage: ${Math.round(rss / (1024 * 1024))}Mb`); + // Stop after 5 seconds. if (Date.now() - start > 5 * 1000) { - // wait 10 seconds. clearInterval(interval); testContextLeak(); @@ -47,11 +47,8 @@ const interval = setInterval(function() { }, 1); function testContextLeak() { + // TODO: This needs a comment explaining what it's doing. Will it crash the + // test if there is a memory leak? Or what? for (let i = 0; i < 1000; i++) vm.createContext({}); } - -process.on('exit', function() { - console.error(`max mem: ${Math.round(maxMem / (1024 * 1024))}mb`); - assert.ok(maxMem < 64 * 1024 * 1024); -}); |