Skip to content

Gen-0 collections happens more frequently on macOS #12717

Description

@smoogipoo

We've observed the GC running much more frequently on .NET Core 3.0 preview 5 than .NET Core 2.2.5 on macOS.

The data I provide may be replicated via the following benchmark:

[MemoryDiagnoser]
public class ConcurrentQueueBenchmarks
{
    [Benchmark]
    public ConcurrentQueue<int> Queue()
    {
        return new ConcurrentQueue<int>();
    }
}
Method Mean Error StdDev Gen 0 Gen 1 Gen 2 Allocated
macOS (.NET Core 2.2.5) 96.63 ns 0.8469 ns 0.7922 ns 0.2441 - - 768 B
macOS (.NET Core 3.0-preview5) 278.4 ns 1.203 ns 1.066 ns 3.5210 - - 576 B
Windows (.NET Core 2.2.5) 104.2 ns 2.094 ns 1.958 ns 0.2440 - - 768 B
Windows (.NET Core 3.0-preview5) 97.15 ns 0.5990 ns 0.5002 ns 0.1836 - - 576 B
Ubuntu 18.04 (.NET Core 2.2.5) 113.8 ns 7.344 ns 21.42 ns 0.2440 - - 768 B
Ubuntu 18.04 (.NET Core 3.0-preview5) 93.64 ns 5.161 ns 15.22 ns 0.1836 - - 576 B

This is not only exhibited by ConcurrentQueue; for example, Lazy experiences a similar ~10x increase in Gen 0 collections per 1000 instances.

I'm unsure of how to debug this further (please let me know how to, if required) - going this deep into the CLR without memory profiling tools on macOS is outside of my area of expertise at the moment.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions