2 using System.Threading;
5 public class NonBridge {
6 public object a,b,c,d,e,f,g,h,i,j,k,l,m,n;
10 public object a,b,c,d,e,f,g,h,i,j,k,l,m,n;
16 //we fill 16Mb worth of stuff, eg, 256k objects
17 const int major_fill = 1024 * 256;
19 //4mb nursery with 64 bytes objects -> alloc half
20 const int nursery_obj_count = 16 * 1024;
22 static void CrashMainLoop () {
23 var arr = new object [major_fill];
24 for (int i = 0; i < major_fill; ++i)
25 arr [i] = new NonBridge ();
27 Console.WriteLine ("major fill done");
29 //induce massive fragmentation
30 for (int i = 0; i < major_fill; i += 4) {
36 Console.WriteLine ("fragmentation done");
38 //since 50% is garbage, do 2 fill passes
39 for (int j = 0; j < 2; ++j) {
40 for (int i = 0; i < major_fill; ++i) {
44 arr [i] = new Bridge ();
47 Console.WriteLine ("done spewing bridges");
49 for (int i = 0; i < major_fill; ++i)
57 for (int i = 0; i < loops; ++i) {
58 Console.WriteLine ("CrashLoop {0}/{1}", i + 1, loops);
61 Console.WriteLine ("done");
63 GC.WaitForPendingFinalizers ();
65 GC.WaitForPendingFinalizers ();