ILNumerics Ultimate VSConcreteRetArrayT1, LocalT, InT, OutT, RetT, StorageTDispose Method ILNumerics Ultimate VS Documentation
ILNumerics - Technical Application Development

Namespace: ILNumerics.Core.Arrays
Assembly: ILNumerics.Core (in ILNumerics.Core.dll) Version: 5.3.0.0 (5.3.7131.2749)
Syntax

public void Dispose()

Implements

IDisposableDispose
Remarks

This method is used in rare situations where the return value from an ILNumerics method is not used. Let's say: the user called a method with OutArrayT parameters and only the output parameter value is needed. If the method has a regular return value (RetArrayT1) this is not released automatically: return values are automatically released after they are used for the _first time_. In order to release the array and to reclaim its storage call Dispose on it.

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 valid 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 return value are 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]

Examples

Array<double> A = rand(10); 
Array<long> I = 1; 
sort(A, Indices: I).Dispose(); // <- cleaning up manually

Here, we only access the output parameter I of the sort function. The array returned from sort(A, I) as the return value is not used, thus it is not released automatically. In order to free its resources immediately, one can call Dispose() on the returned array. Note, that no memory leak is produced without manually calling Dispose(). The array would be cleaned up by the GC instead. For best performance, however, it is recommended to call Dispose() here.

See Also

Reference

ConcreteRetArrayT1, LocalT, InT, OutT, RetT, StorageTDispose
ConcreteArray.Release