Quick start manual
Memory management
11-7
Internal data formats
The NULL character at the end of a wide string memory block is automatically 
maintained by the compiler and the built-in string handling routines. This makes it 
possible to typecast a wide string directly to a null-terminated string.
Note
On Linux, wide strings are implemented exactly as long strings.
Set types
A set is a bit array where each bit indicates whether an element is in the set or not. 
The maximum number of elements in a set is 256, so a set never occupies more than 
32 bytes. The number of bytes occupied by a particular set is equal to
(Max div 8) – (Min div 8) + 1
where Max and Min are the upper and lower bounds of the base type of the set. The 
byte number of a specific element E is
(E div 8) – (Min div 8)
and the bit number within that byte is
E mod 8
where E denotes the ordinal value of the element. When possible, the compiler stores 
sets in CPU registers, but a set always resides in memory if it is larger than the 
generic Integer type or if the program contains code that takes the address of the set.
Static array types
A static array is stored as a contiguous sequence of variables of the component type 
of the array. The components with the lowest indexes are stored at the lowest 
memory addresses. A multidimensional array is stored with the rightmost 
dimension increasing first.
Dynamic array types
A dynamic-array variable occupies four bytes of memory which contain a pointer to 
the dynamically allocated array. When the variable is empty (uninitialized) or holds 
a zero-length array, the pointer is nil and no dynamic memory is associated with the 
variable. For a nonempty array, the variable points to a dynamically allocated block 
of memory that contains the array in addition to a 32-bit length indicator and a 32-bit 
reference count. The table below shows the layout of a dynamic-array memory block.
Table 11.3 Dynamic array memory layout 
Offset Contents
–8 32-bit reference-count
–4 32-bit length indicator (number of elements)
0..Length * (size of element) – 1 array elements










