2020-04-22 10:28:20 +08:00
|
|
|
// Flags: --expose-gc
|
|
|
|
|
|
|
|
'use strict';
|
|
|
|
const common = require('../common');
|
|
|
|
const {
|
|
|
|
assertSummaryShape,
|
|
|
|
expectExperimentalWarning
|
|
|
|
} = require('../common/measure-memory');
|
|
|
|
const vm = require('vm');
|
|
|
|
|
|
|
|
expectExperimentalWarning();
|
|
|
|
|
2025-01-22 15:30:30 -08:00
|
|
|
// Test lazy memory measurement - we will need to globalThis.gc()
|
2020-04-22 10:28:20 +08:00
|
|
|
// or otherwise these may not resolve.
|
|
|
|
{
|
|
|
|
vm.measureMemory()
|
|
|
|
.then(common.mustCall(assertSummaryShape));
|
2025-01-22 15:30:30 -08:00
|
|
|
globalThis.gc();
|
2020-04-22 10:28:20 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
{
|
|
|
|
vm.measureMemory({})
|
|
|
|
.then(common.mustCall(assertSummaryShape));
|
2025-01-22 15:30:30 -08:00
|
|
|
globalThis.gc();
|
2020-04-22 10:28:20 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
{
|
|
|
|
vm.measureMemory({ mode: 'summary' })
|
|
|
|
.then(common.mustCall(assertSummaryShape));
|
2025-01-22 15:30:30 -08:00
|
|
|
globalThis.gc();
|
2020-04-22 10:28:20 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
{
|
|
|
|
vm.measureMemory({ mode: 'detailed' })
|
|
|
|
.then(common.mustCall(assertSummaryShape));
|
2025-01-22 15:30:30 -08:00
|
|
|
globalThis.gc();
|
2020-04-22 10:28:20 +08:00
|
|
|
}
|