SAP MEMORY CONSUMPTION 2



Get Example source ABAP code based on a different SAP table
  



Maximum Size of Dynamic Data Objects
In addition to the maximum memory size that the current ABAP_ISESS can request for dynamic data objects, their maximum size is limited by the following factors:
An upper limit for the number of places in strings or lines of internal tables results from the fact that 4 byte integers are used to address them internally and in ABAP statements, which limits them to 2147483647.
The size of strings and hashed tables is limited by the biggest memory block that can be requested in one piece.
BEGIN_SECTION VERSION 5 OUT This is a maximum of 2 GB but is usually further limited using the profile parameter ztta/max_memreq_MB. For strings, the value of the profile parameter corresponds directly to the maximum size that can be occupied. The maximum number of lines in hashed tables depends on the required size of the hash administration that must be stored there. Currently, it is calculated from the largest power of two that fits into the value of the profile parameter divided by 8. For example, if the profile parameter specifies 250 MB, a hashed table can contain a maximum of about 16 million entries (128 times 1024 to the power of two divided by 8).
The actual maximum size is generally smaller than specified by the above limits since the overall available memory is normally not only used by a string or an internal table.
END_SECTION VERSION 5 OUT
If an operation with a dynamic data object exceeds its maximum size, an exception occurs:
For internal tables, such an exception is uncatchable and always results in a runtime error. There are different runtime errors for different situations, as for example TSV_TNEW_PAGE_ALLOC_FAILED.
For strings, the exception is class-based and connected to exception class CX_SY_STRING_SIZE_TOO_LARGE. The runtime error STRING_SIZE_TOO_LARGE only occurs if the exception is not handled. After this exception is caught, the respective string contains the content it had directly before the exception. This is usually the content it had before the entire operation (statement, function). Exceptions from this rule are statements like CONCATENATE LINES OF or functions like concat_lines_of, which can change the string before the exception occurs.



Latest notes:

If there is only little memory space available, it may be better to use an internal table, because its memory space is requested in blocks, while the entire memory space required for a string must always be free as a whole.
It is strongly recommended that the content of a string after catching an exception CX_SY_STRING_SIZE_TOO_LARGE is regarded as undefined and that it is deleted as soon as possible.
NON_V5_HINTS
ABAP_HINT_END

ABAP_EXAMPLE_VX5
In the following DO loop of class CL_DEMO_STRING_SIZE_TOO_LARGE, a string is concatenated with itself until it exceeds its maximum size and an exception occurs. After catching the exception, the byte-length of the string is determined before its content is deleted.
ABEXA 01425
ABAP_EXAMPLE_END