[REBOL] Re: Sameness - a pragmatic approach.
From: g:santilli:tiscalinet:it at: 11-Feb-2003 18:23
Hi Ladislav,
On Tuesday, February 11, 2003, 4:55:58 PM, you wrote:
LM> Although we have thousand identical O's, the memory
LM> consumption is bigger than for one O exactly like in the case
LM> of 1's. Interestingly enough, the memory consumed additionally
LM> is the same in both cases.
But that is the memory consumed by the block, not the objects
themselves.
>> system/stats == 3772264
>> b: make block! 1000 == []
>> system/stats == 3788648
so that we have:
>> o: make object! [a: 1 b: 2]
>> system/stats == 3788648
>> insert/dup b o 1000 == []
>> system/stats == 3788648
while:
>> clear b == []
>> system/stats == 3792752
>> loop 1000 [insert tail b make o []] == []
>> system/stats == 3891232
Now the fact that the space a block uses is enough to keep simple
values in it without needing further memory allocations does not
mean that those simple values are not taking memory; thinking in
abstract, if you could decouple the block from the values it
contains, having 1000 "1"s would take 1000 times the space taken
by one "1".
Regards,
Gabriele.
--
Gabriele Santilli <[g--santilli--tiscalinet--it]> -- REBOL Programmer
Amigan -- AGI L'Aquila -- REB: http://web.tiscali.it/rebol/index.r