Skip to content

Instantly share code, notes, and snippets.

@ayende
Created November 26, 2019 09:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ayende/62095f4b7cad04e8d36b04c8a79e904e to your computer and use it in GitHub Desktop.
Save ayende/62095f4b7cad04e8d36b04c8a79e904e to your computer and use it in GitHub Desktop.
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