ILNumerics Ultimate VS

CellDispose Method

ILNumerics Ultimate VS Documentation
ILNumerics - Technical Application Development

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

public void Dispose()

This method is used in rare situations where no artificial scope exists around the current function body. Examples of such situations are short ArrayT snippets 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 recycling.

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 and no 'common' memory management is possible for some reasons.

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