ILNumerics Ultimate VS

LogicalDispose Method

ILNumerics Ultimate VS Documentation
ILNumerics - Technical Application Development

Namespace:  ILNumerics
Assembly:  ILNumerics.Core (in ILNumerics.Core.dll) Version: 5.5.0.0 (5.5.7503.3146)
Syntax

public void Dispose()
Remarks

This method is used in rare situations where no artificial scope exists around the current function body. Examples of such situations are short ArrayTsnippets in anonymous- or lambda functions, entry methods, or intended manual memory management.

During 'normal' use the user places an artificial scope (Enter(BaseArray, NullableArrayStyles)) around the function body. All ArrayT, Cell, and Logical arrays created within the scope block are automatically tracked and released once the scope block is left.

Calling this method manually on local arrays as ArrayT & Co. can be profitible in situations where no such scope block exists. Otherwise, the memory would be reclaimed at a later point in time by the GC. Dispose releases the array immediately. If no other arrays are sharing the same memory, it will be released to the memory pool for immediate reusage.

Note: failing to call Dispose in such situations does not create a memory leak! But the array is only reclaimed by the garbage collector and its memory is only freed by the finalization thread during the next GC collection. While this is considered regular use, disposing the array manually is recommended in situations where high performance execution or low memory consumption is required.

Note further, that Dispose is not required in 'common' array uses. I.e. when dealing with ArrayT inside existing Enter(BaseArray, NullableArrayStyles) scope blocks or when a return value is utilized in some way (incl. assignment to ArrayT, calling member functions on the return value or giving the return value to other functions as input parameter).

[ILNumerics Core Module]

See Also

Reference