mirror of
https://github.com/nodejs/node.git
synced 2025-05-03 20:29:36 +00:00

Previously this can be flaky because the there could be a delay of the deallocation after gc() is invoked. Use gcUntil() to run the GC multiple times to make the test more robust. PR-URL: https://github.com/nodejs/node/pull/49168 Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
34 lines
881 B
JavaScript
34 lines
881 B
JavaScript
'use strict';
|
|
// Flags: --expose-gc
|
|
|
|
const common = require('../common');
|
|
|
|
// 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 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();
|