[Mono-dev] Size of thread in Mono (65MB per thread?)

Nikita Tsukanov keks9n at gmail.com
Fri Dec 20 08:34:24 UTC 2013

In normal circumstances (i. e. physical machine, right type of
virtualization, etc) virtual memory address space is almost free, so many
applications reserve large amounts of it. However, until they really need
that memory, no physical memory is used. OpenVZ and such solutions are
using virtual memory limit (that's why you'll have problems using apache2
on 100MB OpenVZ VPS and it'll run fine on Xen/KVM with the same amount of

So the only thing you could do is changing your virtualization software.
Try to play with mono runtime options, but I'm not sure that'll be


2013/12/20 Nicolas Antoniazzi <nicolas.antoniazzi at gmail.com>

> I am not using OpenVZ but a solution that we developed based on Linux
> kernel calls because we really need to bootstrap a virtual environment in
> less than 50ms.
> I tested the same program on a .Net platform and after 1000 threads
> created, the whole application used 48MB of RAM. It sounds really strange
> to me that a Thread, that in theory should be a light process, takes 65MB
> of virtual memory.
> In the meantime, I am not expert in differences between virtual and
> physical memory, but, does your answer mean that if mono would detects that
> my system only has 500MB of physical memory, it would reserve less amount
> of memory per thread?
> Maybe there is a way to send some parameters to mono or to change some
> content in /proc to simulate a smaller amount of physical memory?
> Thanks for your answer!
> 2013/12/20 Nikita Tsukanov <keks9n at gmail.com>
>> Don't use OpenVZ, it limits _virtual_ memory, not physical. Mono threads
>> use a small amount of physical memory, but might reserve high of virtual
>> memory space. You'd rather try KVM/Xen virtualization.
>> Regards,
>> Nikita
>> 2013/12/19 Nicolas Antoniazzi <nicolas.antoniazzi at gmail.com>
>>> Hi,
>>> I am using Mono in a virtualized environment with 512MB of RAM.
>>> I made a very simple program which starts 10 threads in a loop and
>>> apparently, every time that I start a new thread, approximately 65MB of
>>> memory is used.
>>> In my case, I can run 5 threads, but for the 6th, the program crashes
>>> (without any exception). 150MB are already consumed without the use of any
>>> thread.
>>> Is it a normal behavior?
>>> P.S: Sorry I double posted this message on mono-list because I did not
>>> understood that third party programmers also had to come on this devel list.
>>> Thanks!
>>> --
>>> Nicolas Antoniazzi
>>> _______________________________________________
>>> Mono-devel-list mailing list
>>> Mono-devel-list at lists.ximian.com
>>> http://lists.ximian.com/mailman/listinfo/mono-devel-list
>> _______________________________________________
>> Mono-devel-list mailing list
>> Mono-devel-list at lists.ximian.com
>> http://lists.ximian.com/mailman/listinfo/mono-devel-list
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.ximian.com/pipermail/mono-devel-list/attachments/20131220/6ac0f489/attachment.html>

More information about the Mono-devel-list mailing list