Instance details - Size

Use this forum for questions on how to use .NET Memory Profiler and how to analyse memory usage.
Post Reply
user42
Posts: 1
Joined: Mon Mar 06, 2006 5:10 pm

Instance details - Size

Post by user42 » Mon Mar 06, 2006 5:18 pm

Hello,

I've created a simple class with no fields. If I view the details of an instance of this class then the size is: 12. Why?

Andreas Suurkuusk
Posts: 1029
Joined: Wed Mar 02, 2005 7:53 pm

Post by Andreas Suurkuusk » Tue Mar 07, 2006 5:25 pm

Each instance that is allocated on the heap contains a 4-byte vtable pointer and a 4-byte syncblock index (which is used when the instance is used as a monitor). Additionally the runtime will not create instances that are smaller than 12 bytes, so instances of a class that contains a 4-byte field will not consume more memory than an instance of a class that doesn't contain any fields.
Best regards,

Andreas Suurkuusk
SciTech Software AB

Post Reply

Who is online

Users browsing this forum: Majestic-12 [Bot] and 20 guests