Questions tagged [suppressfinalize]

This method sets a bit in the object header of obj, which the runtime checks when calling finalizers. Objects that implement the IDisposable interface can call this method from the object's IDisposable.Dispose implementation to prevent the garbage collector from calling Object.Finalize on an object that does not require it.

This method sets a bit in the object header of obj, which the runtime checks when calling finalizers.

Objects that implement the IDisposable interface can call this method from the object's IDisposable.Dispose implementation to prevent the garbage collector from calling Object.Finalize on an object that does not require it.

Doc: https://learn.microsoft.com/en-us/dotnet/api/system.gc.suppressfinalize

18 questions
1
vote
1 answer

In the TimedLock why is SuppressFinalize(tl.leakDetector) needed?

http://www.interact-sw.co.uk/iangblog/2004/04/26/yetmoretimedlocking Why is this line needed? System.GC.SuppressFinalize(tl.leakDetector); I would have thought the finalizer should not be suppress to run the code that alerts to a left over…
CodingThunder
  • 923
  • 2
  • 9
  • 12
0
votes
0 answers

Can the C# Disposable Pattern be simplified when only _unmanaged_ resources are at play?

(Note: this question is related to Calling GC.SuppressFinalize() from within a finalizer but is not a duplicate, as this question is explicitly specifically about the case of no managed resources, whereas that one is explicitly about when having…
Tom
  • 4,910
  • 5
  • 33
  • 48
0
votes
1 answer

Why Finalizer should not be called after manually calling destructor ( by delete) in C++ CLI

After refer this article which talks about the difference of destructor& finalizer IN C++ CLI, I wonder why compiler add some instrs. to suppress the finalize in destructor? Dose finalize function not stand for "In finally, it will be called by GC"…
tirth
  • 813
  • 1
  • 8
  • 16
1
2