[Mono-list] Memory leak

Alan McGovern alan.mcgovern at gmail.com
Sat Feb 7 10:24:06 EST 2009


Hi,

Can you clarify: are you referring to Mono/gmcs or .NET/VC# here?

I have always been talking about VS/.NET.

In this case, I suspect Mono is leaving a pointer to an unreachable
> temporary
> in the stack frame of the "Main" function and the conservative scan has to
> assume that it is a genuine root.


I suspect this is exactly what was stated in the third response on this
thread.


> Unfortunately, that bogus root does not
> correspond to anything in the C# source code so the programmers only hope
> to
> avoid this bug is to randomly rewrite their code and hope that the
> compiler's
> rearrangements do not reintroduce the problem (e.g. by inlining).

No need to do that, just follow the documented workaround and null the
'next' pointer when detaching from the list.


    static void pop()
    {
        var current = tail;
        var next = tail.next;
        var nextnext = tail.next.next;
        current.next = nextnext;
        next.next = null;
    }

This fixes the issue under MS.NET and under Mono.

Alan.


>
>
> --
> Dr Jon Harrop, Flying Frog Consultancy Ltd.
> http://www.ffconsultancy.com/?e
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.ximian.com/pipermail/mono-list/attachments/20090207/b5b7ce04/attachment.html 


More information about the Mono-list mailing list