Sign in | Join
Last post 06-23-2009 4:24 AM by sumitd. 6 replies.
Sort Posts: Oldest to newest Newest to oldest
Does Visual Studio debugger offer any mechanism to determine object size at runtime?
It not is there any other way to do that (without writing by hand)?
hilberthilbert:Does Visual Studio debugger offer any mechanism to determine object size at runtime?
What do you mean by Object size?
As far as I know I don't think there's a property in VS do this
you can add breakpoints and access the properties of that object
Also you can read this discussions
http://www.geekinterview.com/question_details/50406
http://bytes.com/groups/net/159867-object-size
For example - class AAA { int x; char[] y; }
The actual size of objects of this type will be the sum of two fields (x - always 4 bytes, and the current size of y array that can vary).
I want to know the actual size of AAA object at runtime.
Could you provide a code example, or idea of how can it be done by hand?
I need for example a function that calculates the size of any object independent of it's and contained objects types (reference or value).
You should consider using Performance Counters or Tracing:
http://msdn.microsoft.com/en-us/library/bb386420.aspx
http://msdn.microsoft.com/en-us/library/fxk122b4.aspx
http://www.getdotnetcode.com/GdncStore/free/Articles/Getting%20Started%20With%20Performance%20Counters.htm
http://forums.asp.net/t/1274475.aspx
Use CLR Profiler:
http://msdn.microsoft.com/en-us/library/ms979205.aspx
http://www.microsoft.com/downloads/details.aspx?familyid=CD5AA57C-9CD1-45AB-AA4B-8DC586D30938&displaylang=en
http://www.microsoft.com/downloads/details.aspx?FamilyID=a362781c-3870-43be-8926-862b40aa0cd0&DisplayLang=en