What is the memory overhead of an Object in .NET? I’m talking about an arbitrary bare-bones object…. the overhead of the internal .NET workings or references:
var obj = new System.Object();
How much space does obj occupy in the heap?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
I talk about this in a blog post “Of memory and strings”. It’s implementation-specific, but for the Microsoft .NET CLR v4, the x86 CLR has a per-object overhead of 8 bytes, and the x64 CLR has a per-object overhead of 16 bytes.
However, there are minimum sizes of 12 and 24 bytes respectively – it’s just that you get the first 4 or 8 bytes “free” when you start storing useful information 🙂
(See the blog post for more information.)