0
0
mirror of https://github.com/nodejs/node.git synced 2024-11-21 21:19:50 +01:00
nodejs/test/parallel/test-v8-serialize-leak.js
tannal 0b6b2a4dc7
test: merge ongc and gcutil into gc.js
PR-URL: https://github.com/nodejs/node/pull/54355
Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com>
Reviewed-By: Chengzhong Wu <legendecas@gmail.com>
2024-08-29 08:49:52 +01:00

35 lines
903 B
JavaScript

'use strict';
// Flags: --expose-gc
const common = require('../common');
const { gcUntil } = require('../common/gc');
// On IBMi, the rss memory always returns zero
if (common.isIBMi)
common.skip('On IBMi, the rss memory always returns zero');
const v8 = require('v8');
const before = process.memoryUsage.rss();
for (let i = 0; i < 1000000; i++) {
v8.serialize('');
}
async function main() {
await gcUntil('RSS should go down', () => {
const after = process.memoryUsage.rss();
if (common.isASan) {
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();