Skip to content

Commit 971b7ac

Browse files
Trottrichardlau
authored andcommitted
test: simplify test-vm-memleak
PR-URL: #34881 Reviewed-By: James M Snell <[email protected]> Reviewed-By: Franziska Hinkelmann <[email protected]>
1 parent 29b048b commit 971b7ac

File tree

1 file changed

+5
-8
lines changed

1 file changed

+5
-8
lines changed

test/pummel/test-vm-memleak.js

+5-8
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@ const assert = require('assert');
2727
const vm = require('vm');
2828

2929
const start = Date.now();
30-
let maxMem = 0;
3130

3231
const interval = setInterval(function() {
3332
try {
@@ -36,22 +35,20 @@ const interval = setInterval(function() {
3635
}
3736

3837
const rss = process.memoryUsage().rss;
39-
maxMem = Math.max(rss, maxMem);
38+
assert.ok(rss < 64 * 1024 * 1024,
39+
`memory usage: ${Math.round(rss / (1024 * 1024))}Mb`);
4040

41+
// Stop after 5 seconds.
4142
if (Date.now() - start > 5 * 1000) {
42-
// wait 10 seconds.
4343
clearInterval(interval);
4444

4545
testContextLeak();
4646
}
4747
}, 1);
4848

4949
function testContextLeak() {
50+
// TODO: This needs a comment explaining what it's doing. Will it crash the
51+
// test if there is a memory leak? Or what?
5052
for (let i = 0; i < 1000; i++)
5153
vm.createContext({});
5254
}
53-
54-
process.on('exit', function() {
55-
console.error(`max mem: ${Math.round(maxMem / (1024 * 1024))}mb`);
56-
assert.ok(maxMem < 64 * 1024 * 1024);
57-
});

0 commit comments

Comments
 (0)