ILNumerics Ultimate VS

BaseArrayIsDisposed Property

ILNumerics Ultimate VS Documentation
ILNumerics - Technical Application Development
This flag indicates that an array is not to be used anymore.

[ILNumerics Core Module]

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

public virtual bool IsDisposed { get; }

Property Value

Type: Boolean

Since version 5 arrays implement multiple layers of reference counting and share their resources more frequently. Disposing an array would not dispose its storage while other arrays, sharing the storage still exist. Instead, Dispose decreases the reference counter ReferenceCount of the storage only. The storage becomes disposed only when all references have been detached.

Therefore, the property IsDisposed is not suitable to determine the state of the storage. Even after Dispose() was called the property may return false.

In order to determin whether a storage is still alive, inspect (count) the number of live references to it: only if ReferenceCount is 0 the array can be considered 'disposed'.

The only array types in version 5 which still implement IDisposable and therefore have a Dispose method are RetArrayT1, RetLogical and RetCell. Call its Dispose method in the (rare) situation where the value returned from a function is of one of these types and not used in any way further-on.

[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.

See Also