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: use gcUntil() in test-v8-serialize-leak #49168

Merged
merged 1 commit into from
Aug 18, 2023
Merged
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
26 changes: 15 additions & 11 deletions test/parallel/test-v8-serialize-leak.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,22 +8,26 @@ if (common.isIBMi)
common.skip('On IBMi, the rss memory always returns zero');

const v8 = require('v8');
const assert = require('assert');

const before = process.memoryUsage.rss();

for (let i = 0; i < 1000000; i++) {
v8.serialize('');
}

global.gc();

const after = process.memoryUsage.rss();

if (process.config.variables.asan) {
assert(after < before * 10, `asan: before=${before} after=${after}`);
} else if (process.config.variables.node_builtin_modules_path) {
assert(after < before * 4, `node_builtin_modules_path: before=${before} after=${after}`);
} else {
assert(after < before * 2, `before=${before} after=${after}`);
async function main() {
await common.gcUntil('RSS should go down', () => {
const after = process.memoryUsage.rss();
if (process.config.variables.asan) {
console.log(`asan: before=${before} after=${after}`);
return after < before * 10;
} else if (process.config.variables.node_builtin_modules_path) {
console.log(`node_builtin_modules_path: before=${before} after=${after}`);
return after < before * 10;
}
console.log(`before=${before} after=${after}`);
return after < before * 10;
});
}

main();