Memory Requirements for Deep Data Objects
The memory requirement for a deep data object consists of constantly required memory for the reference and dynamically required memory for the header and the actual objects.
- The memory requirement for the reference is 8 byte. With data and object references, this is the memory requirement of the explicitly declared reference variable. With strings, internal tables, and boxed components, an implicit reference is created internally. As long as no dynamic memory is requested, the memory requirement for a string, internal table, or boxed component is exactly 8 bytes.
- The dynamic memory consists of a header (string header, table header, box header, or object header) and the actual data (string, table body, substructure, anonymous data object, or class instance). The reference points to the header, which in turn contains the address of the actual data and additional administrative information. The following graphic illustrates the memory usage of deep data objects.
Dynamic memory (header and data) is requested:
- For data and object references by creating objects
- For dynamic data
objects (strings and internal tables) by inserting content. For internal tables, the memory is requested
in blocks. The initial size of a block can be influenced by the
INITIAL SIZEaddition when defining an internal table.
When a deep data object is initialized with
FREE, the actual data is deleted, but the reference variables and, for
dynamic data objects also the header, are retained. The latter is reused when memory is requested again.
The memory requirement of a dynamic data object that is used once and then deleted therefore consists
of the reference and the memory requirement of the header, with the exception of boxed components. Only
when using the
FREE statement on internal tables are table headers sometimes
deleted if they would take up too much memory. For static components, initialization does not currently lead to memory being released. Initializing a static box that the
initial value sharing
has been canceled for does not delete the instance in the internal session, but assigns its initial values with suitable types to the instance.
The memory requirement of the different headers is approximately as follows:
- For performance reasons, the memory usage of a string header depends on the length of the string. Strings with a length of less than around 30 characters/60 bytes are called short strings. The memory overhead of the string header of short strings is between approximately 10 and 40 bytes, depending on the length of the string. For all other strings, the overhead is approximately 50 bytes, regardless of the string length.
- A table header of an internal table that dynamic memory has already been requested for is around 100 bytes, regardless of the line usage. For filled internal tables, about another 50 or 100 bytes is required for pointers, depending on whether the architecture is 32 or 64-bit.
- A box header of a boxed component always uses approximately 20 to 30 bytes.
- An object header always uses around 30 bytes.
For internal tables, there are additional row-related administration costs in the header. This memory is not created in the table header, but is created in parallel to the table body. This means that when rows are deleted, the corresponding administration data is also deleted.