[Mono-dev] Finalizers in CriticalHandle

Rodrigo Kumpera kumpera at gmail.com
Fri Jan 14 11:26:04 EST 2011


I suppose it is. Does .NET call Release on finalizer?

On Fri, Jan 14, 2011 at 4:30 PM, Dick Porter <dporter at codicesoftware.com>wrote:

> Hi all
>
> I'm currently debugging an issue that appears to be caused by the
> non-release of unmanaged resources in CriticalHandle.  I'm using the git
> master branch.
>
> In CriticalHandle.cs:
>
>                [ReliabilityContract (Consistency.WillNotCorruptState,
> Cer.Success)]
>                ~CriticalHandle ()
>                {
>                        Dispose (false);
>                }
>
>                [ReliabilityContract (Consistency.WillNotCorruptState,
> Cer.Success)]
>                protected virtual void Dispose (bool disposing)
>                {
>                        if (_disposed)
>                                return;
>
>                        _disposed = true;
>                        if (IsInvalid)
>                                return;
>
>                        if (disposing == true && !IsInvalid){
>                                if (!ReleaseHandle ()) {
>                                        GC.SuppressFinalize (this);
>                                } else {
>                                        // Failed in release...
>                                }
>                        }
>                }
>
>
> Unless I'm missing something, this looks to me that when the
> CriticalHandle object is finalized, the unmanaged resources won't be
> released: ReleaseHandle() isn't called.
>
> Is this a bug?
>
> - Dick
>
>
> _______________________________________________
> Mono-devel-list mailing list
> Mono-devel-list at lists.ximian.com
> http://lists.ximian.com/mailman/listinfo/mono-devel-list
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.ximian.com/pipermail/mono-devel-list/attachments/20110114/93a03460/attachment-0001.html 


More information about the Mono-devel-list mailing list