title: Memory usage of a node class of a LinkedList in java (enclosing instance reference)
body: <p>In page 201 of Sedgewick's <em>algorithms4</em> book, the memory taken up by a <code>Node</code> is given as 40 bytes:</p>
  
  <pre><code>class Node{
      Item item;
      Node next;
  } 
  </code></pre>
  
  <p>The breakdown given is:</p>
  
  <ul>
  <li>object overhead = 16 bytes</li>
  <li>item reference = 8 bytes (=memory address) </li>
  <li>next reference = 8 bytes</li>
  <li>extra overhead = 8 bytes</li>
  </ul>
  
  <p>The explanation for extra overhead is:</p>
  
  <blockquote>
    <p>A nested non static (inner)class as our Node class (page 142) require an extra 8 bytes (for reference to the enclosing instance)</p>
  </blockquote>
  
  <p>What is this <strong>enclosing instance</strong> he mentions? The <code>Node</code> class only contains <code>item</code> and <code>next</code> variables.</p>
  
  <p>Can someone clarify this?</p>