2 using System.Threading;
5 This test stresses what happens when root domain threads are allocating into the nursery
6 while a domain is cleaned up.
8 This is a regression test for a crash in the domain object cleaner code that did not
9 stop-the-world before walking the heap.
12 static void AllocStuff ()
14 var x = new object ();
15 for (int i = 0; i < 300; ++i)
19 static void BackgroundNoise ()
26 var testTimeout = new TestTimeout ();
28 for (int i = 0; i < Math.Max (1, Environment.ProcessorCount / 2); ++i) {
29 // for (int i = 0; i < 4; ++i) {
30 var t = new Thread (BackgroundNoise);
31 t.IsBackground = true;
35 const int TOTAL_ITERATIONS = 100;
36 for (int i = 0; i < TOTAL_ITERATIONS; ++i) {
37 var ad = AppDomain.CreateDomain ("domain_" + i);
38 ad.DoCallBack (new CrossAppDomainDelegate (AllocStuff));
39 AppDomain.Unload (ad);
42 if (i > 0 && i % 20 == 0) Console.WriteLine ();
44 if (!testTimeout.HaveTimeLeft ()) {
45 var finishTime = DateTime.UtcNow;
46 var ranFor = finishTime - testTimeout.StartTime;
47 Console.WriteLine ("Will run out of time soon. ran for {0}, finished {1}/{2} iterations", ranFor, i+1, TOTAL_ITERATIONS);
50 Console.WriteLine ("\ndone");