console.log('=== Testing Ant.alloc() ==='); let alloc1 = Ant.alloc(); console.log('Initial allocation:'); console.log(' used:', alloc1.used); console.log(' minFree:', alloc1.minFree); console.log('\n=== Creating objects to allocate memory ==='); let arr = []; for (let i = 0; i < 100; i = i + 1) { arr.push({ value: i, name: 'item' + i }); } console.log('Created array with 100 objects'); let alloc2 = Ant.alloc(); console.log('After allocation:'); console.log(' used:', alloc2.used); console.log(' minFree:', alloc2.minFree); console.log(' increase:', alloc2.used - alloc1.used); console.log('\n=== Testing Ant.stats() ==='); let stats1 = Ant.stats(); console.log('Memory stats:'); console.log(' used:', stats1.used); console.log(' minFree:', stats1.minFree); console.log(' cstack:', stats1.cstack); console.log('\n=== Testing Ant.gc() ==='); arr = null; let gcResult = Ant.gc(); console.log('GC result:'); console.log(' before break:', gcResult.before); console.log(' after break:', gcResult.after); console.log(' freed bytes:', gcResult.freed); console.log('\n=== Verifying memory after GC ==='); let alloc3 = Ant.alloc(); console.log('After GC:'); console.log(' used:', alloc3.used); console.log(' minFree:', alloc3.minFree); console.log('\n=== Testing multiple GC cycles ==='); for (let cycle = 0; cycle < 3; cycle = cycle + 1) { console.log('Cycle', cycle + 1); let temp = []; for (let i = 0; i < 50; i = i + 1) { temp.push({ data: 'test data ' + i }); } let beforeGc = Ant.alloc(); console.log(' Before GC - used:', beforeGc.used); temp = null; let gc = Ant.gc(); console.log(' After GC - used:', gc.after, 'freed bytes:', gc.freed); } console.log('\n=== Testing stats consistency ==='); let statsA = Ant.stats(); let allocA = Ant.alloc(); console.log('Stats and alloc should match:'); console.log(' stats.used:', statsA.used); console.log(' alloc.used:', allocA.used); console.log(' match:', statsA.used === allocA.used); console.log('\n=== Test complete ===');