11cb0ef41Sopenharmony_ci// Flags: --expose-gc
21cb0ef41Sopenharmony_ci
31cb0ef41Sopenharmony_ci'use strict';
41cb0ef41Sopenharmony_ciconst common = require('../common');
51cb0ef41Sopenharmony_ciconst {
61cb0ef41Sopenharmony_ci  assertSummaryShape,
71cb0ef41Sopenharmony_ci  expectExperimentalWarning
81cb0ef41Sopenharmony_ci} = require('../common/measure-memory');
91cb0ef41Sopenharmony_ciconst vm = require('vm');
101cb0ef41Sopenharmony_ci
111cb0ef41Sopenharmony_ciexpectExperimentalWarning();
121cb0ef41Sopenharmony_ci
131cb0ef41Sopenharmony_ci// Test lazy memory measurement - we will need to global.gc()
141cb0ef41Sopenharmony_ci// or otherwise these may not resolve.
151cb0ef41Sopenharmony_ci{
161cb0ef41Sopenharmony_ci  vm.measureMemory()
171cb0ef41Sopenharmony_ci    .then(common.mustCall(assertSummaryShape));
181cb0ef41Sopenharmony_ci  global.gc();
191cb0ef41Sopenharmony_ci}
201cb0ef41Sopenharmony_ci
211cb0ef41Sopenharmony_ci{
221cb0ef41Sopenharmony_ci  vm.measureMemory({})
231cb0ef41Sopenharmony_ci    .then(common.mustCall(assertSummaryShape));
241cb0ef41Sopenharmony_ci  global.gc();
251cb0ef41Sopenharmony_ci}
261cb0ef41Sopenharmony_ci
271cb0ef41Sopenharmony_ci{
281cb0ef41Sopenharmony_ci  vm.measureMemory({ mode: 'summary' })
291cb0ef41Sopenharmony_ci    .then(common.mustCall(assertSummaryShape));
301cb0ef41Sopenharmony_ci  global.gc();
311cb0ef41Sopenharmony_ci}
321cb0ef41Sopenharmony_ci
331cb0ef41Sopenharmony_ci{
341cb0ef41Sopenharmony_ci  vm.measureMemory({ mode: 'detailed' })
351cb0ef41Sopenharmony_ci    .then(common.mustCall(assertSummaryShape));
361cb0ef41Sopenharmony_ci  global.gc();
371cb0ef41Sopenharmony_ci}
38