The easiest way to test if memory that is deAlloc'ed can be reused is to alloc and deAlloc a large block, then try to alloc many smaller blocks.
let block = Memory.alloc(10000);
do Memory.deAlloc(block);
let i = 10;
while (i > 0) {
let block = Memory.alloc(1000);
let i = i-1
}
Since heap is 14K, there will not be enough memory to allocate the ten smaller blocks if the large block was not put back into use.
More challenging is to get this test to run:
let block1 = Memory.alloc(2000);
let block2 = Memory.alloc(2000);
let block3 = Memory.alloc(2000);
let block4 = Memory.alloc(2000);
let block5 = Memory.alloc(2000);
do Memory.deAlloc(block3); // random order
do Memory.deAlloc(block5);
do Memory.deAlloc(block2);
do Memory.deAlloc(block1);
do Memory.deAlloc(block4);
let block = Memory.alloc(10000);
This requires that contiguous small deAlloc'ed blocks be combined to satisfy the alloc. This process is called defragmentation.