Saving memory by using dynamic arrays

The language supports both static arrays and dynamic arrays. For compatibility reasons, static arrays must be allocated in their entirety. This can result in huge memory usage when big structures are declared, such as:
DEFINE my_array ARRAY[100,50] OF RECORD
      id CHAR(200),
      comment1 CHAR(2000),
      comment2 CHAR(2000)
END RECORD

If possible, replace such static arrays with dynamic arrays:

DEFINE my_array DYNAMIC ARRAY OF RECORD
      id CHAR(200),
      comment1 CHAR(2000),
      comment2 CHAR(2000)
END RECORD

However, be aware that dynamic arrays have a slightly different behavior than static arrays.

After using a large dynamic array, you should clean the content by using the clear() method. This will free all the memory used by the array elements. However, this is only needed for arrays declared as global or module variables. The arrays defined in functions will be automatically cleaned and destroyed when the program returns from the function.