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