[Mono-list] Memory leak
Jon Harrop
jon at ffconsultancy.com
Sat Feb 7 10:10:46 EST 2009
On Saturday 07 February 2009 14:04:28 you wrote:
> If you compile the code without optimisations, it leaks indefinitely. If
> you compile with optimisations, the compiler generated variable is being
> optimised away and so it doesn't leak.
Can you clarify: are you referring to Mono/gmcs or .NET/VC# here?
> So, as was stated before and as is stated in the boehm docs, this issue is
> *not* limited to conservative garbage collectors.
Yes. However, conveying bogus roots to the GC is most certainly a serious bug.
Fortunately, it is easily fixed: just nullify reference types when liveness
analysis proves they are no longer reachable.
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. 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).
--
Dr Jon Harrop, Flying Frog Consultancy Ltd.
http://www.ffconsultancy.com/?e
More information about the Mono-list
mailing list