sample.cs 817 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. using System;
  2. using Mono.ObjectServices;
  3. class Demo {
  4. int a;
  5. static void Main ()
  6. {
  7. Demo d = new Demo ();
  8. prints ("d", d);
  9. prints ("dd", new DD ());
  10. prints ("short str", "short");
  11. prints ("long str", "this is a longer string which we want to measure the size of");
  12. object[] obj_array = new object [100];
  13. prints ("obj array", obj_array);
  14. for (int i = 0; i < 100; i++)
  15. obj_array [i] = new Demo ();
  16. prints ("obj array w/ demos", obj_array);
  17. }
  18. static void prints (string s, object x)
  19. {
  20. Console.WriteLine ("size of " + s + ":" + ObjectInspector.GetMemoryUsage (x));
  21. }
  22. }
  23. class DD {
  24. Demo d = new Demo ();
  25. object [] o = new object [10];
  26. char [] ch = new char [10];
  27. int junk;
  28. public DD ()
  29. {
  30. o [0] = new Demo ();
  31. o [5] = new Demo ();
  32. }
  33. }