internal Array(IntPtr pointer) { #if DEBUG if (pointer == IntPtr.Zero) { throw new ArgumentNullException("Invalid Array Pointer"); } #endif this._ptr = pointer; Interlocked.Increment(ref _instances); if (_instances % 50 == 0) // only do it every time we allocated new 50 instances, we can tweak this { UIntPtr bytes, buffers, lockbytes, lockbuffers; Internal.VERIFY(AFDevice.af_device_mem_info(out bytes, out buffers, out lockbytes, out lockbuffers)); // code borrowed from the R wrapper: if ((double)lockbytes > Math.Pow(1000, 3) || (double)lockbuffers > 50) { GC.Collect(); } } }
public static void PrintInfo() { Internal.VERIFY(AFDevice.af_info()); }
public static void SetDevice(int device) { Internal.VERIFY(AFDevice.af_set_device(device)); }