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

james james at mansionfamily.plus.com
Mon Dec 23 06:44:35 UTC 2013

On 21/12/2013 14:48, Nikita Tsukanov wrote:
> The problem is that there is no anything simular to MEM_RESERVE and 
> MEM_COMMIT from Windows (flags for VirtualAlloc/VirtualAllocEx), so 
> there is no way to properly reserve a large block of virtual address 
> space. BTW, windows threads reserve a lot of address space using 
> MEM_RESERVE and then use SEH/VEH to detect, when memory should be 
> commited, so it uses the same "overcommit" mechanics. You can create a 
> lot of threads with large stacks, try to use it and get out of memory 
> exception when, actually, trying to push something on your stack.
That's nowhere near the same fail.  If I get a good return from malloc 
and then I die when I try to access it, that's bad.

Its nothing like failing because I tried to grow a thread stack and fail 
with OOM - at no point has the OS said 'here's the memory' and then 
renaged on it.  Rather it has said 'here's the address space', which is 
different.  For a start, the program that is trying to get real memory 
is the one that will fail.  On a UNIX system with an OOM handler, its by 
no means the case that the process which is wasting allocated memory is 
the one that will die - it can be anything that made a large alloc 
that's not backed by real VM yet and which tries to access memory it was 
explicitly given by the OS.

In reality with modern systems they get so slow as soon as the working 
set materially exceeds physical that its not often you'll hit random OOM 
death before rebooting the box anyway. :-(

More information about the Mono-devel-list mailing list