Yuka JS的MemorySystem清除所有被分配的内存的函数。
memorySystem.clear()
clear()
方法可以清除当前分配的所有内存。此方法将usedBlocks
清零,并将freeBlocks
列表添加一个节点,从而清除所有内存。
const memorySystem = new Yuka.MemorySystem();
memorySystem.allocateBlock(10);
memorySystem.allocateBlock(20);
memorySystem.clear();
console.log(memorySystem.usedBlocks.length);
// output: 0
console.log(memorySystem.freeBlocks.head.nextNode.start);
// output: 0
console.log(memorySystem.freeBlocks.head.nextNode.size);
// output: size of the entire memory block
N/A.