[ILNumerics Core Module]
Namespace: ILNumerics.Core.Arrays
Assembly: ILNumerics.Core (in ILNumerics.Core.dll) Version: 5.5.0.0 (5.5.7503.3146)
Implements
IDisposableDisposeNote: 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]
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.