LabVIEW handles many of the memory details that you normally deal with in a conventional, text-based language. For example, functions that generate data must allocate storage for the data. When that data is no longer needed, LabVIEW deallocates the associated memory. When you add new information to an array or a string, LabVIEW allocates new memory to accommodate the new array or string. However, running out of memory is a concern with VIs running on an RT target.
You must design memory-conscious VIs for RT targets. Always preallocate space for arrays equal to the largest array size that you might encounter.
When you reboot or reset an RT target, the RTOS and the RT Engine load into memory as shown in diagram 1 of the following figure.

The RT Engine uses available memory for running RT target VIs and storing data. In diagram 2, ArrayMaker.vi creates Array 1. All elements in Array 1 must be contiguous in memory.
The RTOS reuses the same memory addresses if you stop a VI and then run it again with arrays of the same size or smaller. In diagram 3, ArrayMaker.vi creates Array 2. The RTOS creates Array 2 in the reserved memory space previously occupied by Array 1. Array 2 is small enough to fit in the reserved memory space that was allocated to Array 1. The extra contiguous memory used for Array 1 remains in the reserved memory space, as shown in diagram 3.
When ArrayMaker.vi runs for a third time with a larger array or if another VI generates a larger array, the RT Engine must find a large enough contiguous space. In diagram 4, ArrayMaker.vi must create Array 3, larger than the previous arrays, in the available memory.
Even when ArrayMaker.vi stops running, the RT Engine continues to run. Previously reserved memory is not available. If ArrayMaker.vi runs a fourth time and attempts to create an array larger than Array 3, the operation fails. There is no contiguous memory area large enough to create the array because of the memory fragmentation. You can preserve memory space by preallocating array space equal to the largest use case.