2 * The string portion of this test crashes on Boehm (and there might
3 * not be much we can do about that - I haven't looked into it), and
4 * the array portions are unbearably slow, so it's only run on SGen.
11 public static void Test (Action
<int> allocator
)
13 for (int i
= 0; i
< 1000; ++i
)
18 //Console.WriteLine ("allocating with " + i);
21 catch (OutOfMemoryException
)
28 Console.WriteLine ("WTF?");
29 //Environment.Exit (1);
35 public static void Ignore
<T
> (T x
)
39 public static void ProbeArray
<T
> (T
[] a
)
44 for (int i
= 0; i
< 1000; ++i
)
47 a
[a
.Length
- i
- 1] = default (T
);
51 public static void ProbeString (string s
)
53 for (int i
= 0; i
< 1000; ++i
)
55 if (s
[s
.Length
- i
- 1] != ' ')
60 public static int Main ()
62 Console
.WriteLine ("byte arrays");
63 Test (i
=> ProbeArray (new byte [int.MaxValue
- i
]));
64 Test (i
=> ProbeArray (new byte [int.MaxValue
- i
* 100]));
66 Console
.WriteLine ("int arrays");
67 Test (i
=> ProbeArray (new int [int.MaxValue
/ 4 - i
]));
68 Test (i
=> ProbeArray (new int [int.MaxValue
/ 4 - i
* 100]));
70 Console
.WriteLine ("large int arrays");
71 Test (i
=> ProbeArray (new int [int.MaxValue
- i
]));
72 Test (i
=> ProbeArray (new int [int.MaxValue
- i
* 100]));
74 // FIXME: This commit 4gb of memory
76 Console.WriteLine ("strings");
77 Test (i => ProbeString ("abcd".PadRight(int.MaxValue - i)));
78 Test (i => ProbeString ("abcd".PadRight(int.MaxValue - i * 100)));
81 //Console.WriteLine ("no objects allocated - all good");