Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test: simplify test-vm-memleak #34881

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 5 additions & 8 deletions test/pummel/test-vm-memleak.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ const assert = require('assert');
const vm = require('vm');

const start = Date.now();
let maxMem = 0;

const interval = setInterval(function() {
try {
Expand All @@ -36,22 +35,20 @@ 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();
}
}, 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);
});