1'use strict'; 2const common = require('../common'); 3const { 4 assertDetailedShape, 5 expectExperimentalWarning 6} = require('../common/measure-memory'); 7const vm = require('vm'); 8const assert = require('assert'); 9 10expectExperimentalWarning(); 11{ 12 const arr = []; 13 const count = 10; 14 for (let i = 0; i < count; ++i) { 15 const context = vm.createContext({ 16 test: new Array(100).fill('foo') 17 }); 18 arr.push(context); 19 } 20 // Check that one more context shows up in the result 21 vm.measureMemory({ mode: 'detailed', execution: 'eager' }) 22 .then(common.mustCall((result) => { 23 // We must hold on to the contexts here so that they 24 // don't get GC'ed until the measurement is complete 25 assert.strictEqual(arr.length, count); 26 assertDetailedShape(result, count + common.isWindows); 27 })); 28} 29