[Mono-list] Memory leak

Alan McGovern alan.mcgovern at gmail.com
Sat Feb 7 08:11:41 EST 2009


Hey,

Sorry, i meant to say what mistake did *you* make porting it to C# as
it leaks indefinitely under MS.NET too.

Alan.

On Sat, Feb 7, 2009 at 1:08 PM, Alan McGovern <alan.mcgovern at gmail.com> wrote:
> Hi,
>
> Could you point out the mistake i made in porting your example to C#,
> because it leaks forever on MS.NET too.
>
> Thanks,
> Alan.
>
>
> using System;
>
> class Leak
> {
>    class Cell<A>
>    {
>        public A content;
>        public Cell<A> next;
>    }
>
>    static Cell<int[]> tail = null;
>
>    static void Push(int[] x)
>    {
>        var tail2 = tail;
>        var cell = new Cell<int[]> { content = x, next = tail2.next };
>        tail2.next = cell;
>        tail = cell;
>    }
>
>    static void Pop()
>    {
>        var tail3 = tail;
>        tail3.next = tail3.next.next;
>    }
>
>    static void Main()
>    {
>        var cell = new Cell<int[]> { content = new int[0], next = null };
>        cell.next = cell;
>        tail = cell;
>
>        while (true)
>        {
>            Push(new int[] { 1, 2, 3, 4 });
>            Pop();
>        }
>    }
> }
>


More information about the Mono-list mailing list