Simulated heap: 1024 bytes, 8-byte alignment, first-fit. Type 'help'.
heap> alloc 100
allocated #1 (100 bytes requested)
heap> alloc 200
allocated #2 (200 bytes requested)
heap> alloc 50
allocated #3 (50 bytes requested)
heap> alloc 300
allocated #4 (300 bytes requested)
heap> map
[11111122222222222223334444444444444444444.......................]
      0-  103    104 bytes  #1
    104-  303    200 bytes  #2
    304-  359     56 bytes  #3
    360-  663    304 bytes  #4
    664- 1023    360 bytes  free
heap> free 2
freed #2
heap> free 3
freed #3
heap> map
[111111................4444444444444444444.......................]
      0-  103    104 bytes  #1
    104-  359    256 bytes  free
    360-  663    304 bytes  #4
    664- 1023    360 bytes  free
heap> alloc 120
allocated #5 (120 bytes requested)
heap> alloc 500
allocation of 500 bytes FAILED (no free block large enough)
heap> stats
strategy first-fit | used 528 / 1024 bytes (51.6%) in 3 block(s)
free 496 bytes in 2 block(s), largest 360 | external fragmentation 27.4%
allocations 5, frees 2, failed requests 1
heap> free 1
freed #1
heap> free 4
freed #4
heap> map
[......55555555..................................................]
      0-  103    104 bytes  free
    104-  223    120 bytes  #5
    224- 1023    800 bytes  free
heap> init 512 best
heap reset: 512 bytes, best-fit
heap> alloc 64
allocated #1 (64 bytes requested)
heap> alloc 128
allocated #2 (128 bytes requested)
heap> alloc 64
allocated #3 (64 bytes requested)
heap> free 2
freed #2
heap> alloc 40
allocated #4 (40 bytes requested)
heap> map
[1111111144444...........33333333................................]
      0-   63     64 bytes  #1
     64-  103     40 bytes  #4
    104-  191     88 bytes  free
    192-  255     64 bytes  #3
    256-  511    256 bytes  free
heap> compare
strategy     failures   largest free   frag %
first-fit           0             40     61.5
best-fit            0             88     15.4
worst-fit           0             64     38.5
heap> quit
bye
