Created
September 27, 2018 18:14
-
-
Save ayende/3788b7cebc63c1cdd7ab614186e6ca78 to your computer and use it in GitHub Desktop.
This file contains 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
class Program | |
{ | |
static ManualResetEvent _produce = new ManualResetEvent(false); | |
static ManualResetEvent _consume = new ManualResetEvent(false); | |
private static void Run() | |
{ | |
while (true) | |
{ | |
_produce.WaitOne(); | |
_produce.Reset(); | |
var b = new byte[1024 * 1024 * 128]; | |
MD5.Create().ComputeHash(b); | |
b = null; | |
Console.WriteLine("Done"); | |
_consume.Set(); | |
} | |
} | |
static void Main(string[] args) | |
{ | |
new Thread(Run) | |
{ | |
IsBackground = true, | |
}.Start(); | |
while (true) | |
{ | |
_produce.Set(); | |
_consume.WaitOne(); | |
_consume.Reset(); | |
GC.Collect(2); | |
GC.WaitForPendingFinalizers(); | |
Console.WriteLine(GC.GetTotalMemory(true)); | |
Console.ReadLine(); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment