title: Examining memory layout in Java
body: <p>I am experimenting with inheritance and for educational purposes want to examine the addresses allocated for various objects and the fields within the object. Is there a tool which will let me see what memory the JVM is using and what it is using it for.</p>
  
  <p>For example if I have two classes:</p>
  
  <pre><code>class A { int i,j; int f { ...} }
  class B extends A { int c; /* more methods, overriding f and declaring new ones as well */ }
  </code></pre>
  
  <p>and instantiate these classes in objects <code>a</code> and <code>b</code>.</p>
  
  <p>Is there a tool I can use to profile the memory usage and see exactly what memory is allocated for these?</p>
  
  <p>Thank you!</p>