eerhardt commented on code in PR #35496: URL: https://github.com/apache/arrow/pull/35496#discussion_r1190107596
########## csharp/src/Apache.Arrow/Memory/ExportedAllocationOwner.cs: ########## @@ -0,0 +1,55 @@ +// Licensed to the Apache Software Foundation (ASF) under one or more +// contributor license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright ownership. +// The ASF licenses this file to You under the Apache License, Version 2.0 +// (the "License"); you may not use this file except in compliance with +// the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +using System; +using System.Collections.Generic; +using System.Runtime.InteropServices; + +namespace Apache.Arrow.Memory +{ + internal sealed class ExportedAllocationOwner : INativeAllocationOwner, IDisposable + { + private readonly List<IntPtr> _pointers = new List<IntPtr>(); + private int _allocationSize; + + ~ExportedAllocationOwner() + { + Dispose(); Review Comment: Only the `virtual Dispose(bool)` part applies to non-sealed classes. The part you still want is ` GC.SuppressFinalize(this);` when `Dispose()` is called on the object. >> The Dispose method performs all object cleanup, so the garbage collector no longer needs to call the objects' [Object.Finalize](https://learn.microsoft.com/en-us/dotnet/api/system.object.finalize) override. Therefore, the call to the [SuppressFinalize](https://learn.microsoft.com/en-us/dotnet/api/system.gc.suppressfinalize) method prevents the garbage collector from running the finalizer. This has performance advantages because the objects don't need to survive from GC gen 0 to gen 1 just to run the finalizer. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
