import Memory from '../src/memory.js' const mem = new Memory({db:0}) // no debounce // mem.watch(console.dir) // mem.watch() mem.watch( (stats) => { // console.log(stats) console.log('remaining heap after garbage collection>>>',mem.subtract(stats.after.heapSizeLimit,stats.after.usedHeapSize)) }) setInterval(()=> mem.emit('tick') ,5000) mem.on('tick',()=> { // mem.clog({msg:'testing', props:'all', str:true}) // console.dir(mem.snapshot()) console.log('remaining heap at snapshot@@@@',mem.snapshot().remaining) let text for (let i = 0; i < 1000000; i++) { text += 'a' } mem.text = text console.log('memory that text is using', mem.sizeof(mem.text),mem.sizeof(text), 'M') })