[Mono-list] Memory leak
alan.mcgovern at gmail.com
Sat Feb 7 10:24:06 EST 2009
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
> 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
> Unfortunately, that bogus root does not
> correspond to anything in the C# source code so the programmers only hope
> avoid this bug is to randomly rewrite their code and hope that the
> 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.
> Dr Jon Harrop, Flying Frog Consultancy Ltd.
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Mono-list