Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 76d991c

Browse filesBrowse files
Trottaddaleax
authored andcommitted
test: simplify test-vm-memleak
PR-URL: #34881 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Franziska Hinkelmann <franziska.hinkelmann@gmail.com>
1 parent 9b53b4d commit 76d991c
Copy full SHA for 76d991c

File tree

Expand file treeCollapse file tree

1 file changed

+5
-8
lines changed
Open diff view settings
Filter options
Expand file treeCollapse file tree

1 file changed

+5
-8
lines changed
Open diff view settings
Collapse file

‎test/pummel/test-vm-memleak.js‎

Copy file name to clipboardExpand all lines: test/pummel/test-vm-memleak.js
+5-8Lines changed: 5 additions & 8 deletions
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 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.