Created
April 28, 2017 02:10
-
-
Save jkotas/46ed0ae0363a2fbe97600b566168bb9c to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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