[interp] Remove unreachable code (#12411)
[mono-project.git] / mono / tests / gc-oom-handling2.cs
blobe048113fb050d0740cd2cea4af611bb1a4a5f8e6
1 using System;
2 using System.Collections.Generic;
3 using System.Reflection;
6 class Driver {
7 /*Test that GC handles interning failure correctly*/
8 static void DumpStuff () {
9 Console.WriteLine ("CWL under OOM - should not print {0}", 99);
10 Console.WriteLine ("CWL under OOM - should not print {0}{1}", 22, 44.4);
13 static int Main () {
14 Console.WriteLine ("start");
15 Assembly corlib = typeof (object).Assembly;
16 Module module = corlib.GetModules ()[0];
17 var r = new Random (123456);
18 var l = new List<object> ();
19 try {
20 for (int i = 0; i < 400000; ++i) {
21 var foo = new byte[r.Next () % 4000];
22 l.Add (foo);
24 Console.WriteLine ("done");
25 return 1;
26 } catch (Exception) {
27 try {
28 DumpStuff ();
29 return 2;
30 } catch (Exception) {}
32 try {
33 module.GetTypes ();
34 return 3;
35 } catch (Exception) {}
37 try {
38 corlib.GetTypes ();
39 return 4;
40 } catch (Exception) {}
43 l.Clear ();
44 l = null;
45 Console.WriteLine ("OOM done");
47 return 0;