X++ Standards: Arrays [AX 2012]
Updated: November 30, 2011
Applies To: Microsoft Dynamics AX 2012 R3, Microsoft Dynamics AX 2012 R2, Microsoft Dynamics AX 2012 Feature Pack, Microsoft Dynamics AX 2012
This topic describes the best practice for using the memory option in arrays. For more information, see Arrays.
The memory option is the optional second array declaration option. It specifies how many consecutive entries in the array will be held in memory at a particular time. The rest will reside on disk (a cached temporary file, indexed by the array index).
Dynamic arrays are sized according to the maximum index used.
Use the memory option to limit the amount of RAM used to hold the data of the array when you work with high numbered indexes (and large cells).
If you use all (or nearly all) of the entries in an array, set the memory option to a large number, or do not set it at all.
If you only use a few of the entries in the array, set the memory option to a small number, such as 1.
If you consider using the memory option on an array where you use all (or almost all) of the entries, the look up performance should be considered.
If you traverse an array sequentially, such as with an index of 1, 2, 3, ..., n, you will probably not experience any read performance problems. The cell data blocks will be read sequentially from disk and they will be read to the end before the next block is read (disk reads will be number of entries/memory option size).
If you traverse an array randomly (such as with an index of 300, 20, 5, 250, n, ..., 50) the cell data will also be read from disk randomly, so you may experience read performance problems (disk reads could be as high as the number of entries).
Announcements: To see known issues and recent fixes, use Issue search in Microsoft Dynamics Lifecycle Services (LCS).