CLR: How is 0 generated for all threads?

I cannot imagine that there is one lock that all threads must receive in order to allocate memory. So is there a few Gen 0 heaps? Is there one that is split between threads?

+7
source share
1 answer

From this article: Garbage Collection Part 2: Automatic Memory Management in the Microsoft .NET Framework by Jeffrey Richter

Distributions without synchronization In a multiprocessor system, the generation of a managed heap is divided into several memory areas using one arena per thread. This allows multiple threads to make allocations at the same time, so exclusive access to the heap is not required.

Scalable collections In a multiprocessor system running the server version of the execution engine (MSCorSvr.dll), the managed heap is divided into several sections, one for each processor. When collection is initiated, the collector has one thread per processor; all threads collect their sections at the same time. The runtime engine workstation version (MSCorWks.dll) does not support this feature.

There are many other things, see the heading "Performance for multithreaded applications."

+7
source

All Articles