0

If I have:

int[] d = {1,2,3};

which is the exact allocated space in memory of the array object referenced by d?

Is it only 3 * 4 = 12 byte or there are other bytes like in Java (i.e. object header, padding, and so on)?

P.S. I noticed that I can't use sizeof operator...

4
  • 1
    What exactly are you trying to do? Memory measurement in managed languages is more complex like unmanaged ones like c#, so sizeof is not as straight-forward an operation. Commented Dec 7, 2015 at 14:13
  • 4
    Have a look here: http://stackoverflow.com/questions/1589669/overhead-of-a-net-array It shows hat the overhead for a reference type array is 16 bytes wheras the overhead for a value type array is 12 bytes. Commented Dec 7, 2015 at 14:13
  • Yes, there are more bytes also allocated. Where did you get the idea of sizeof? This is not C++. This is completely different language. Actually, you can do something like sizeof with Marshal.SizeOf Commented Dec 7, 2015 at 14:14
  • Have another look here: stackoverflow.com/questions/207592/… Commented Dec 7, 2015 at 14:14

0

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.