Skip to content

Instantly share code, notes, and snippets.

@jkotas
Created April 28, 2017 02:10
Show Gist options
  • Select an option

  • Save jkotas/46ed0ae0363a2fbe97600b566168bb9c to your computer and use it in GitHub Desktop.

Select an option

Save jkotas/46ed0ae0363a2fbe97600b566168bb9c to your computer and use it in GitHub Desktop.
using System;
using System.Runtime.CompilerServices;
using Internal.Runtime.Augments;
class Program
{
static void Fill(ConditionalWeakTable<object,object> cwt)
{
Object[] o = new object[1000000];
for (int i = 0; i < o.Length; i++)
cwt.Add(o[i] = new object(), new object());
}
static volatile int x = 1;
static void Work() {
while (x != 0) x += 2;
}
static int Main()
{
var cwt = new ConditionalWeakTable<object,object>();
Fill(cwt);
RuntimeThread.Create(Work).Start();
for (;;) { new object[1000].ToString(); GC.KeepAlive(cwt); RuntimeThread.Sleep(1); }
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment