PR-URL: https://github.com/nodejs/node/pull/56712 Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com> Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
38 lines
747 B
JavaScript
38 lines
747 B
JavaScript
// Flags: --expose-gc
|
|
|
|
'use strict';
|
|
const common = require('../common');
|
|
const {
|
|
assertSummaryShape,
|
|
expectExperimentalWarning
|
|
} = require('../common/measure-memory');
|
|
const vm = require('vm');
|
|
|
|
expectExperimentalWarning();
|
|
|
|
// Test lazy memory measurement - we will need to globalThis.gc()
|
|
// or otherwise these may not resolve.
|
|
{
|
|
vm.measureMemory()
|
|
.then(common.mustCall(assertSummaryShape));
|
|
globalThis.gc();
|
|
}
|
|
|
|
{
|
|
vm.measureMemory({})
|
|
.then(common.mustCall(assertSummaryShape));
|
|
globalThis.gc();
|
|
}
|
|
|
|
{
|
|
vm.measureMemory({ mode: 'summary' })
|
|
.then(common.mustCall(assertSummaryShape));
|
|
globalThis.gc();
|
|
}
|
|
|
|
{
|
|
vm.measureMemory({ mode: 'detailed' })
|
|
.then(common.mustCall(assertSummaryShape));
|
|
globalThis.gc();
|
|
}
|