microsoft / dotnet

This repo is the official home of .NET on GitHub. It's a great starting point to find many .NET OSS projects from Microsoft and the community, including many that are part of the .NET Foundation.
https://devblogs.microsoft.com/dotnet/
MIT License
14.43k stars 2.21k forks source link

GC is fucking sheat..... try this, you are fucking monkeys #1453

Closed NikitaBeliayev closed 2 weeks ago

NikitaBeliayev commented 2 weeks ago

using System; using System.Linq; using System.Collections.Generic;

var list = new List { new { I = Guid.NewGuid() } }; var list1 = new List { new { I = Guid.NewGuid() } }; try { while (true) { if (list1.LongCount() < 10_000_000) { list1.AddRange(list); }

    list.AddRange(list);
    if (list.LongCount() > uint.MaxValue)
    {
        break;
    }
}

} catch { list.Clear(); list1.Clear(); list1 = null; list = null;

var a = GC.GetAllocatedBytesForCurrentThread();
Console.WriteLine("a:" + a);
GC.Collect();
var b = GC.GetAllocatedBytesForCurrentThread();
Console.WriteLine("b:" + b);

}

Console.ReadKey();