How many bytes get allocated for 3 Point structs on a 64-bit processor?
<p>There is a question:</p>
<blockquote>
<p>Given:</p>
<pre><code>struct Point {int x; int y;}
var p = new Point[3]
</code></pre>
<p>how many bytes of memory will be allocated in stack and in heap if we use a 64-bit processor?</p>
</blockquote>
<p>The correct answer for <code>.Net</code> is <em><strong>44</strong></em>. Can somebody explain how did this number appear?</p>
<p>As far as I understand, <code>p</code> will occupy <em><strong>8 bytes</strong></em> in stack for <code>x64</code>.</p>
<p>And we have two values of <code>Int32</code> per structure, thus
<code>p.Length * sizeof(Point)</code>
<em><strong>3 * 8 = 24 bytes</strong></em> in heap for an array.</p>
<p>That will be <em><strong>32 bytes</strong></em>. What is the rest <em><strong>12 bytes</strong></em> for in this case?</p>