Rebol3 Code Examplex
Memory allocation
Show how to explicitly allocate and deallocate blocks of memory.
Rebol [
title: "Rosetta code: Memory allocation"
file: %Memory_allocation.r3
url: https://rosettacode.org/wiki/Memory_allocation
]
recycle/pools
print ["Memory used:" stats]
print "Allocate block for 1'000'000 values..."
blk: make block! 1'000'000
print ["Memory used:" stats]
print "Release the block."
blk: none
recycle
print ["Memory used:" stats]
print "^/Display internal memory info:"
stats/showOutput:
Memory used: 6657382
Allocate block for 1'000'000 values...
Memory used: 38658406
Release the block.
Memory used: 6657382
Display internal memory info:
Series Memory Info:
node size = 32
series size = 32
7 segs = 917616 bytes - headers
11285 blks = 3118944 bytes - blocks
3385 strs = 482984 bytes - byte strings
0 unis = 0 bytes - unicode strings
8 odds = 68352 bytes - odd series
14678 used = 3670280 bytes - total used
13994 free / 2456804 bytes - free headers / node-space
Pool Wide Units Used/Total Used% Segments Bytes-per-pool
Pool[ 0] 8B 512 841/1536 (54%) 3 segs, 12336 total
Pool[ 1] 32B 1024 1514/3072 (49%) 3 segs, 98352 total
Pool[ 2] 64B 512 2033/3072 (66%) 6 segs, 196704 total
Pool[ 3] 96B 1024 4209/8192 (51%) 8 segs, 786560 total
Pool[ 4] 128B 512 1685/3072 (54%) 6 segs, 393312 total
Pool[ 5] 160B 256 1163/1792 (64%) 7 segs, 286832 total
Pool[ 6] 192B 128 608/1024 (59%) 8 segs, 196736 total
Pool[ 7] 224B 128 485/768 (63%) 6 segs, 172128 total
Pool[ 8] 256B 64 337/576 (58%) 9 segs, 147600 total
Pool[ 9] 288B 64 281/512 (54%) 8 segs, 147584 total
Pool[10] 320B 128 205/384 (53%) 3 segs, 122928 total
Pool[11] 352B 64 196/384 (51%) 6 segs, 135264 total
Pool[12] 384B 32 126/192 (65%) 6 segs, 73824 total
Pool[13] 416B 32 198/352 (56%) 11 segs, 146608 total
Pool[14] 448B 32 82/160 (51%) 5 segs, 71760 total
Pool[15] 480B 64 94/192 (48%) 3 segs, 92208 total
Pool[16] 512B 64 55/128 (42%) 2 segs, 65568 total
Pool[17] 640B 32 164/288 (56%) 9 segs, 184464 total
Pool[18] 768B 32 97/224 (43%) 7 segs, 172144 total
Pool[19] 896B 16 72/128 (56%) 8 segs, 114816 total
Pool[20] 960B 16 25/48 (52%) 3 segs, 46128 total
Pool[21] 1024B 16 30/48 (62%) 3 segs, 49200 total
Pool[22] 2048B 64 118/256 (46%) 4 segs, 524352 total
Pool[23] 3072B 4 23/28 (82%) 7 segs, 86128 total
Pool[24] 4096B 8 6/16 (37%) 2 segs, 65568 total
Pool[25] 32B 4096 14678/28672 (51%) 7 segs, 917616 total
Pool[26] 84B 128 1/128 ( 0%) 1 segs, 10768 total
Pool[27] 24B 256 0/256 ( 0%) 1 segs, 6160 total
Pools used 2864412 of 5323648 (53%)
System pool used 1275904