Forum Discussion

michaelveloz's avatar
New Contributor
14 years ago

Confused about object size -- always 24?

Hi there

I am a new user to AQTime and I'm trying to test debug a tiny c# application to make sure I understand the results shown from the Allocation Profiler.

I am confused about the size of objects created.

I create an instance of the following object, during certain button click event, and save a reference to this object into a form variable (to make sure it's not garbage collected and that AQTime can see it)

 public class Class1 {


        Int32[] a = new Int32[25000];

         public Class1() {

            for (Int32 ix = 0; ix < a.Length; ix++) {

                a[ix] = ix;





After clicking the button and doing a "Get Results" in AQTime, I can  see the object in both the class view and the object view, but in both cases, the size of the object is reported as 24. I don't understand what this is telling me??

I changed the size of the "a" array to different values and am still seeing "24" as the size..??

Thanks for any info you might provide!


2 Replies

  • I think I'm starting to see the light: I'm only seeing the size of the declared fields in the class - but not the size of the contents of those fields and fields they may contain, etc.

    In other words, I'm seeing the "top level" fields allocated but nothing below that.

    So if I class declares an integer array, AQTime might show the 4 bytes (or 8 bytes, whatever) that it takes for an instance of that class to hold that reference.. but if that array is initialized to hold a million entires, AQTime isn't going to show that one million as part of the objects size.. it isn't "recursing" down through all the allocations to come up with an "aggregate" size of the object..

    Is there a way to get it to do this though?


  • Hello Michael,

    You are right, the class instance stores only a reference to the array, not the array itself.

    To see the array object in the profiling results, you need to change some profiling settings:

    - Areas: enable the "Profile Entire .NET Code By Classes" area.

    - Report: disable the "View Project Classes Only" option (find the button on the panel's toolbar).