PageRenderTime 45ms CodeModel.GetById 19ms RepoModel.GetById 0ms app.codeStats 0ms

/mono/tests/sgen-domain-unload.cs

https://bitbucket.org/danipen/mono
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
  1. using System;
  2. using System.Collections.Generic;
  3. public class Bar {
  4. public object a, b, c;
  5. }
  6. class Driver {
  7. static void ProduceSimpleHeapWithLOS () {
  8. Console.WriteLine ("running in {0}", AppDomain.CurrentDomain);
  9. byte[] a = new byte [4 * 1000 * 1000];
  10. byte[] b = new byte [4 * 1000 * 1000];
  11. byte[] c = new byte [4 * 1000 * 1000];
  12. var lst = new List<object> ();
  13. Bar la, lb, lc;
  14. la = lb = lc = null;
  15. for (int i = 0; i < 1000 * 200; ++i) {
  16. var ba = new Bar ();
  17. var bb = new Bar ();
  18. var bc = new Bar ();
  19. ba.a = la;
  20. ba.b = bb;
  21. ba.c = a;
  22. bb.a = bc;
  23. ba.b = b;
  24. bb.c = lb;
  25. bc.a = c;
  26. bc.b = lc;
  27. bc.c = ba;
  28. la = ba;
  29. lb = bb;
  30. lc = bc;
  31. lst.Add (ba);
  32. }
  33. }
  34. static void SimpleHeapWithLOS () {
  35. ProduceSimpleHeapWithLOS ();
  36. }
  37. static void CrossDomainTest (string name, CrossAppDomainDelegate dele) {
  38. Console.WriteLine ("----Testing {0}----", name);
  39. for (int i = 0; i < 20; ++i) {
  40. var ad = AppDomain.CreateDomain (string.Format ("domain-{0}-{1}", name, i));
  41. ad.DoCallBack (dele);
  42. AppDomain.Unload (ad);
  43. }
  44. }
  45. static void Main () {
  46. CrossDomainTest ("simple-heap-with-los", Driver.SimpleHeapWithLOS);
  47. }
  48. }