[Mono-dev] ConcurrentQueue

Natti Shwarts natti.shwarts at gmail.com
Tue Dec 17 16:14:06 UTC 2013


Hi,
I'm running the following .net program on mono (Ubuntu 12, sources
3.8.13.12)
and after ~1 minute where the memory rises up (without any reason according
to the code below), mono crash with TOO MANY HEAP SECTIONS.
(using Queue + lock is stable)
I got mono sources from Git and compile them with large heap.
The result was the same.

I have a few questions:
1. Do you have any idea what could cause this problem ?
2. regarding mono compilation, all makefiles created are with -g flag, how
can I remove it ?

Thanks
Natti



class Program
{
    private static readonly ConcurrentQueue<object> Pool = new
ConcurrentQueue<object>();
    static void Main(string[] args)
    {
        //Fill
        for (var i = 0; i < 500; i++)
            Pool.Enqueue(new object());
        var threads = Enumerable.Range(0, Environment.ProcessorCount)
                                                 .Select(_ => new Thread(()
=>
                                                  {
                                                          while (true)
                                                          {
                                                                  object
obj;
                                                                   if
(Pool.TryDequeue(out obj))

Pool.Enqueue(obj);
                                                           }
                                                    })).ToArray();
                foreach (var t in threads)
                      t.Start();
                Thread.Sleep(Timeout.Infinite);
            }
     }
}
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.ximian.com/pipermail/mono-devel-list/attachments/20131217/5a16990d/attachment.html>


More information about the Mono-devel-list mailing list