Why mono GC does not realloc the heap after collect?

View: New views
2 Messages — Rating Filter:   Alert me  

Why mono GC does not realloc the heap after collect?

by Alex A Ermoshenko :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

//Example code
//On the NetFarmewort - all work fine
//On Mono  - ~105MiB in the heap, after GC.Collect(). Expected ~5 MiB
////////////////
using System;
using System.Collections.Generic;
using System.Text;

namespace mono_gc_test
{
        class Program
        {
                static object alloc100MB()
                {
                        byte[] data = new byte[100 * 1024 * 1024];
                        return data;
                }
                static void msg(string text, bool wait)
                {
                        Console.WriteLine(text);
                        if (wait)
                                Console.ReadLine();
                }
                static void Main(string[] args)
                {
                        object data = null;
                        msg("Mono GC.Collect() realloc test.", false);
                        msg("Press ENTER to alloc 100MiB of data", true);
                        data = alloc100MB();
                        msg("Press ENTER to GC.Collect()", true);
                        data = null;
                        GC.Collect();
                        msg("Press ENTER to exit", true);
                }
        }
}

Re: Why mono GC does not realloc the heap after collect?

by Miguel de Icaza-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Because Mono does not support a collector like this, it uses a different
kind, a conservative collector.

> //Example code
> //On the NetFarmewort - all work fine
> //On Mono  - ~105MiB in the heap, after GC.Collect(). Expected ~5 MiB
> ////////////////
> using System;
> using System.Collections.Generic;
> using System.Text;
>
> namespace mono_gc_test
> {
> class Program
> {
> static object alloc100MB()
> {
> byte[] data = new byte[100 * 1024 * 1024];
> return data;
> }
> static void msg(string text, bool wait)
> {
> Console.WriteLine(text);
> if (wait)
> Console.ReadLine();
> }
> static void Main(string[] args)
> {
> object data = null;
> msg("Mono GC.Collect() realloc test.", false);
> msg("Press ENTER to alloc 100MiB of data", true);
> data = alloc100MB();
> msg("Press ENTER to GC.Collect()", true);
> data = null;
> GC.Collect();
> msg("Press ENTER to exit", true);
> }
> }
> }

_______________________________________________
Mono-list maillist  -  Mono-list@...
http://lists.ximian.com/mailman/listinfo/mono-list