Skip to content

Instantly share code, notes, and snippets.

@ayende
Created September 27, 2018 18:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save ayende/3788b7cebc63c1cdd7ab614186e6ca78 to your computer and use it in GitHub Desktop.
Save ayende/3788b7cebc63c1cdd7ab614186e6ca78 to your computer and use it in GitHub Desktop.
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