Bump corefx
[mono-project.git] / mono / tests / gc-oom-handling.cs
blob3d22294f7d0778cbfdaff9f13b0977e951d96a9a
1 using System;
2 using System.Collections.Generic;
4 class Driver {
5 static int Main () {
6 Console.WriteLine ("start");
7 var l = new object[40000];
8 try {
9 for (int i = 0; i < 40000; ++i) {
10 var foo = new byte[2000];
11 l[i] = foo;
13 Console.WriteLine ("done");
14 return 1;
15 } catch (Exception e) {
16 /*Create massive fragmentation - hopefully*/
17 for (int i = 0; i < 40000; i += 2)
18 l[i] = null;
19 /*Fist major schedule the given block range for evacuation*/
20 GC.Collect ();
21 /*Second major triggers evacuation*/
22 GC.Collect ();
23 Array.Clear (l, 0, 40000);
24 l = null;
25 Console.WriteLine ("OOM done");
27 return 0;