ARM. - Array Operations

<< Click to Display Table of Contents >>

Navigation:  3. Script Language > Arrays and Data-Structures > !ARM. - Multidimensional Dynamic Arrays > Array Management >

ARM. - Array Operations

ARM.EndAll

Previous Top Next


MiniRobotLanguage (MRL)

 

ARM.EndAll

Destroys all two-dimensional arrays, freeing their memory.

 

Intention

 

The ARM.EndAll command destroys all two-dimensional (2D) arrays currently in memory, releasing the resources they occupy. This is a powerful command for memory management in MiniRobotLanguage, ideal for scenarios where a program needs to completely reset or terminate, such as ending a multi-level game, clearing all image layers in an editor, or concluding a series of matrix computations. 2D arrays, visualized as a grid like a chessboard with rows and columns (e.g., [1,1] to [8,8]), are emulated within a one-dimensional structure in MRL, and ARM.EndAll ensures comprehensive cleanup, preventing memory leaks in large applications managing multiple arrays. It’s particularly useful in resource-constrained environments or when transitioning between major application states, but it should be used cautiously as it affects all arrays indiscriminately.

 

Illustration:

🧹 2D Arrays Destruction: All grids (e.g., multiple chessboard-like arrays) are removed from memory, freeing resources for all active 2D arrays.
🔑 Handles: All 2D array handles (e.g., $$ARR1, $$ARR2) are invalidated and no longer usable.

 

Syntax

 

ARM.EndAll

 

Parameter Explanation

 

This command has no parameters. It operates on all 2D arrays currently managed by MiniRobotLanguage, destroying them and freeing their memory without requiring specific handles.

 

Examples

 

'***********************************

' ARM.EndAll - Sample 1: Ending All Game Boards

'***********************************

ARM.New|$$ARR1

ARM.Set|$$ARR1|1|1|King

ARM.New|$$ARR2

ARM.Set|$$ARR2|1|1|Pawn

DBP.2D Arrays before ending: $$ARR1 (chessboard-like) [King, ...], $$ARR2 [Pawn, ...]

ARM.EndAll

DBP.All 2D arrays destroyed, memory freed

'

'***********************************

' ARM.EndAll - Sample 2: Clearing All Image Layers

'***********************************

ARM.New|$$IMG1|f

ARM.Set|$$IMG1|1|1|1.5

ARM.New|$$IMG2|f

ARM.Set|$$IMG2|1|1|-2.7

DBP.2D Arrays (pixel grids) before ending: $$IMG1 [1.5, ...], $$IMG2 [-2.7, ...]

ARM.EndAll

DBP.All 2D arrays destroyed, memory freed

'

'***********************************

' ARM.EndAll - Sample 3: Resetting All Matrices

'***********************************

ARM.New|$$MAT1|i

ARM.Set|$$MAT1|1|1|100

ARM.New|$$MAT2|i

ARM.Set|$$MAT2|1|1|200

DBP.2D Arrays (matrices) before ending: $$MAT1 [100, ...], $$MAT2 [200, ...]

ARM.EndAll

DBP.All 2D arrays destroyed, memory freed

'

 

Remarks

 

- This command affects all 2D arrays in memory, regardless of their handles or purposes, so use it cautiously to avoid unintended data loss in applications like games, image editors, or scientific tools.

- After executing ARM.EndAll, all array handles (e.g., $$ARR1, $$ARR2) become invalid, and any attempt to use them will result in errors; recreate arrays with ARM.New if needed.

- Proper use of ARM.EndAll is vital for maintaining application performance, especially in resource-constrained environments or long-running programs managing multiple 2D arrays, such as multi-player games or complex image processing workflows.

- The performance impact of destroying all 2D arrays is minimal, but ensuring timely cleanup prevents memory bloat, particularly when dealing with numerous arrays (e.g., multiple game boards or layered images).

 

Limitations

 

- This command cannot be selective; it destroys all 2D arrays, potentially leading to data loss if not all arrays are intended for removal.

- There is no undo for ARM.EndAll; once executed, all 2D arrays are permanently destroyed, requiring recreation with ARM.New if needed.

- The command assumes all active handles refer to 2D arrays; using it in an environment with other data types or structures may lead to undefined behavior or errors.

 

See also:

 

ARM.End

ARM.New

ARM.Validate

ARM Commands Overview