/mono/tests/sgen-domain-unload.cs
C# | 59 lines | 48 code | 11 blank | 0 comment | 2 complexity | 2889c0f436d01bddfd55e88f179ac4f5 MD5 | raw file
Possible License(s): Unlicense, Apache-2.0, LGPL-2.0, MPL-2.0-no-copyleft-exception, CC-BY-SA-3.0, GPL-2.0
- using System;
- using System.Collections.Generic;
- public class Bar {
- public object a, b, c;
-
- }
- class Driver {
- static void ProduceSimpleHeapWithLOS () {
- Console.WriteLine ("running in {0}", AppDomain.CurrentDomain);
- byte[] a = new byte [4 * 1000 * 1000];
- byte[] b = new byte [4 * 1000 * 1000];
- byte[] c = new byte [4 * 1000 * 1000];
- var lst = new List<object> ();
- Bar la, lb, lc;
- la = lb = lc = null;
- for (int i = 0; i < 1000 * 200; ++i) {
- var ba = new Bar ();
- var bb = new Bar ();
- var bc = new Bar ();
- ba.a = la;
- ba.b = bb;
- ba.c = a;
- bb.a = bc;
- ba.b = b;
- bb.c = lb;
-
- bc.a = c;
- bc.b = lc;
- bc.c = ba;
- la = ba;
- lb = bb;
- lc = bc;
- lst.Add (ba);
- }
-
- }
- static void SimpleHeapWithLOS () {
- ProduceSimpleHeapWithLOS ();
- }
- static void CrossDomainTest (string name, CrossAppDomainDelegate dele) {
- Console.WriteLine ("----Testing {0}----", name);
- for (int i = 0; i < 20; ++i) {
- var ad = AppDomain.CreateDomain (string.Format ("domain-{0}-{1}", name, i));
- ad.DoCallBack (dele);
- AppDomain.Unload (ad);
- }
- }
- static void Main () {
- CrossDomainTest ("simple-heap-with-los", Driver.SimpleHeapWithLOS);
- }
- }