Skip to content

Instantly share code, notes, and snippets.

@kumpera
Created July 1, 2013 20:06
Show Gist options
  • Select an option

  • Save kumpera/5904093 to your computer and use it in GitHub Desktop.

Select an option

Save kumpera/5904093 to your computer and use it in GitHub Desktop.
using System;
using System.Threading;
class Driver {
static void AllocStuff ()
{
var x = new object ();
for (int i = 0; i < 300; ++i)
x = new byte [i];
}
static void BackgroundNoise ()
{
while (true)
AllocStuff ();
}
static void Main () {
for (int i = 0; i < Environment.ProcessorCount; ++i) {
var t = new Thread (BackgroundNoise);
t.IsBackground = true;
t.Start ();
}
for (int i = 0; i < 100; ++i) {
var ad = AppDomain.CreateDomain ("domain_" + i);
ad.DoCallBack (new CrossAppDomainDelegate (AllocStuff));
AppDomain.Unload (ad);
Console.Write (".");
if (i > 0 && i % 20 == 0) Console.WriteLine ();
}
Console.WriteLine ("\ndone");
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment