Mailing List Archive: 49091 messages
  • Home
  • Script library
  • AltME Archive
  • Mailing list
  • Articles Index
  • Site search
 

[REBOL] Re: TUPLE! DATA-MODEL & OTHER VALUES

From: holger:rebol at: 12-Jun-2001 15:12

On Tue, Jun 12, 2001 at 12:12:42PM -0700, Larry Palmiter wrote:
> Thanks Holger, that is very useful information. I am still a bit puzzled by > the apparent memory allocation for blocks. > > Using REBOL/Core 2.5.0.3.1 > > >> start: system/stats > == 1620752 > >> b: make block! 10000 > == [] > >> system/stats - start / 10000 > == 16.1792 > >> loop 10000 [insert tail b to-decimal random 1000] > == [] > >> system/stats - start / 10000 > == 16.1792 > >> b > == [695 852 380 196 367 232 853 912 304 415 171 632 767 530 257 786 935 620 > 566 441 > 445 704 719 260 715 897 556 599 936 666 728 199... > >> type? first b > == decimal! > > It seems like there are about 16 bytes allocated per element when the empty > block is created, but when I insert 10000 decimal! values at a minimum of 8 > bytes per element into it, the memory allocation does not increase. > > Does this imply the "pointers" for the block elements have room somewhere > for short simple types, or does the block creation simply allocate a certain > amount of space for short simple values? > > Are the values of simple block elements stored consecutively in memory, or > does the block just contain "pointers" to values in the heap?
Conceptually a block is an array of values, and "make block! 10000" ensures that the block has room for 10000 values. That's why you do not see the memory use increase when values are inserted into the block. I am afraid I cannot comment on implementation details. -- Holger Kruse [holger--rebol--com]