[Mono-list] Memory leak

Alan McGovern alan.mcgovern at gmail.com
Fri Feb 6 05:02:25 EST 2009


Hi guys,

Someone emailed me a C# version of the 'leaking' program (leak.cs). As was
stated by Rodrigo, this bug is caused by stack slots not being overrwritten.
I've attached a non leaking version (recurse.cs) which adds some recursion
so the stack slots are overrwritten. This version exhibits no leak and will
run forever.

Jon, so if your application is 'leaking' on mono, it's not due to the list
implementation, unless of course your application performs all it's
operations in the same stack slot.

Alan.

On Mon, Feb 2, 2009 at 6:05 PM, Paolo Molaro <lupus at ximian.com> wrote:

> On 02/01/09 Jon Harrop wrote:
> > This code creates a queue represented by a cyclic list and repeatedly
> adds and
> > takes one element at a time (so there are always either 1 or 2 elements
> in
> > the queue). Running on Mono 2.2, this program leaks, consuming all 4Gb of
> my
> > memory in only 60 seconds.
>
> If your description of the code is correct, it shouldn't "leak" even with
> the Boehm GC. Write the equivalent code in C#, for example. My guess is
> that either your code doesn't do what you describe or there is a bug
> triggered by F# in the runtime and what is actually leaking is not
> managed memory. Post the equivalent C# code and we can easily check
> which case it is.
>
> > I understand that Mono's new garbage collector has been delayed until
> Mono 2.9
> > but someone else mentioned that even this new GC will still not be
> accurate
> > and, therefore, is likely to leak memory indefinitely as well. Is that
> > correct?
>
> There are various degrees of GC precisions: the current GC is already
> precise wrt heap objects and basically only thread stacks are scanned
> conservatively. The new GC does the same (though there are
> a few more little-used memory locations that are scanned precisely).
> Precise scanning of the managed stack frames is planned for a subsequent
> release (it requires JIT changes as well).
>
> lupus
>
> --
> -----------------------------------------------------------------
> lupus at debian.org                                     debian/rules
> lupus at ximian.com                             Monkeys do it better
> _______________________________________________
> Mono-list maillist  -  Mono-list at lists.ximian.com
> http://lists.ximian.com/mailman/listinfo/mono-list
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.ximian.com/pipermail/mono-list/attachments/20090206/d0697512/attachment.html 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: leak.cs
Type: text/x-csharp
Size: 959 bytes
Desc: not available
Url : http://lists.ximian.com/pipermail/mono-list/attachments/20090206/d0697512/attachment.bin 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: recurse.cs
Type: text/x-csharp
Size: 1081 bytes
Desc: not available
Url : http://lists.ximian.com/pipermail/mono-list/attachments/20090206/d0697512/attachment-0001.bin 


More information about the Mono-list mailing list