[2020-02] Avoid following invalid pointers in mono_w32process_get_modules on Darwin...
[mono-project.git] / mono / tests / sgen-domain-unload.cs
blobb2bfc5e153ea43ec73e6064f6f0e5aef032e6ad8
1 using System;
2 using System.Collections.Generic;
4 public class Bar {
5 public object a, b, c;
8 class Driver {
9 static void ProduceSimpleHeapWithLOS () {
10 Console.WriteLine ("running in {0}", AppDomain.CurrentDomain);
11 byte[] a = new byte [4 * 1000 * 1000];
12 byte[] b = new byte [4 * 1000 * 1000];
13 byte[] c = new byte [4 * 1000 * 1000];
14 var lst = new List<object> ();
16 Bar la, lb, lc;
17 la = lb = lc = null;
18 for (int i = 0; i < 1000 * 200; ++i) {
19 var ba = new Bar ();
20 var bb = new Bar ();
21 var bc = new Bar ();
22 ba.a = la;
23 ba.b = bb;
24 ba.c = a;
26 bb.a = bc;
27 ba.b = b;
28 bb.c = lb;
30 bc.a = c;
31 bc.b = lc;
32 bc.c = ba;
34 la = ba;
35 lb = bb;
36 lc = bc;
38 lst.Add (ba);
43 static void SimpleHeapWithLOS () {
44 ProduceSimpleHeapWithLOS ();
47 static void CrossDomainTest (string name, CrossAppDomainDelegate dele) {
48 TestTimeout timeout = TestTimeout.Start (TimeSpan.FromSeconds(TestTimeout.IsStressTest ? 60 : 5));
49 Console.WriteLine ("----Testing {0}----", name);
50 for (int i = 0; timeout.HaveTimeLeft; ++i) {
51 var ad = AppDomain.CreateDomain (string.Format ("domain-{0}-{1}", name, i));
52 ad.DoCallBack (dele);
53 AppDomain.Unload (ad);
57 static void Main () {
58 CrossDomainTest ("simple-heap-with-los", Driver.SimpleHeapWithLOS);