protected virtual void Dispose(bool disposing) { if (disposing) { // free managed resources } // free native resources if (handle.IsAllocated) { handle.Free(); ptrData = IntPtr.Zero; } }