using System; | |
using System.Collections.Generic; | |
namespace ConsoleApp28 | |
{ | |
class Program | |
{ | |
static void Main(string[] args) | |
{ | |
var keys = new List<ulong>(); | |
var values = new List<ulong>(); | |
var wyRng = new WyHash.WyRng(0); | |
for (int i = 0; i < 1_000_000; i++) | |
{ | |
keys.Add(wyRng.NextLong()); | |
values.Add(wyRng.NextLong()); | |
} | |
var before = GC.GetTotalMemory(true); | |
var dic = new Dictionary<ulong, ulong>(); | |
for (int i = 0; i < 1_000_000; i++) | |
{ | |
dic[keys[i]] = values[i]; | |
} | |
for (int i = 0; i < 5; i++) | |
{ | |
GC.Collect(2); | |
GC.WaitForPendingFinalizers(); | |
} | |
var after = GC.GetTotalMemory(true); | |
Console.WriteLine(after - before); | |
GC.KeepAlive(dic); | |
GC.KeepAlive(keys); | |
GC.KeepAlive(values); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment