[Mono-bugs] [Bug 388376] New: Mono is unable to properly release memory

bugzilla_noreply at novell.com bugzilla_noreply at novell.com
Thu May 8 13:31:49 EDT 2008


https://bugzilla.novell.com/show_bug.cgi?id=388376


           Summary: Mono is unable to properly release memory
           Product: Mono: Runtime
           Version: 1.9.0
          Platform: 32bit
        OS/Version: RHEL 4
            Status: NEW
          Severity: Blocker
          Priority: P5 - None
         Component: GC
        AssignedTo: lupus at novell.com
        ReportedBy: antonello.moro at elsagdatamat.com
         QAContact: mono-bugs at lists.ximian.com
          Found By: Other


Mono does not release memory, even after calling GC.Collect and
GC.WaitForPendingFinalizers.
This means that if an object (whose size is equals to 10MB, for example) is set
to null, the total size of memory used by mono will not decrement after having
called GC.Collect.
Mono seems no to be able to release memory even when it is required, so, when
large objects are created and destroyed, sooner or later mono crashes due to
OutOfMemoryException.

The problem is present both in windows and linux OS.

In order to reproduce the bug, please run the following code

[CODE]
using System;
using System.Collections.Generic;
using System.Text;
using System.Diagnostics;

namespace ConsoleApplication1
{
    class Program
    {

        static void Main(string[] args)
        {
            int numByte = 600000000;
            Console.WriteLine("Proc Id: " + Process.GetCurrentProcess().Id);
            Console.WriteLine("Creating array");
            byte[] p = new byte[numByte];

            Console.WriteLine("Array created");
            for (int i = 0; i < numByte; i++)
            {
                p[i] = 20;
            }


            p = null;
            Console.WriteLine("Collecting");
            GC.Collect();
            System.GC.WaitForPendingFinalizers();
            Console.WriteLine("Execution terminated, press any key");
            Console.ReadLine();


        }
    }
}
[/CODE]

Using taksmanager (or top in linux) you can see that the memory allocated by
mono is the same before and after the GC.Collect has been invoked.


The following code causes mono to crash during the third execution, due to a
OutOfMemoryException, while the same code never crashes when running under
MS.NET

[CODE]
using System;
using System.Collections.Generic;
using System.Text;
using System.Diagnostics;

namespace ConsoleApplication1
{
    class Program
    {
        //private static int convMb = 1048576;

        static void Main(string[] args)
        {
            int numByte = 600000000;
            Console.WriteLine("Proc Id: " + Process.GetCurrentProcess().Id);
            while (true)
            {
                Console.WriteLine("Creating array");
                byte[] p = new byte[numByte];

                Console.WriteLine("Array created");
                for (int i = 0; i < numByte; i++)
                {
                    p[i] = 20;
                }


                p = null;
                Console.WriteLine("Collecting");
                GC.Collect();
                System.GC.WaitForPendingFinalizers();
            }


        }
    }
}
[/CODE]


-- 
Configure bugmail: https://bugzilla.novell.com/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the QA contact for the bug.


More information about the mono-bugs mailing list