title: object size in Java
body: <p>Suppose I have:</p>
  
  <pre><code>Class A{
     int a;
  }
  
  A obj = new A();
  </code></pre>
  
  <p>Then what will be size of obj? Will it be of same size as int size, like in C?</p>
  
  <p>If I can figure out this, then I can keep large HashMap in RAM without using database.</p>
  
  <p>Thanks in advance.</p>
  
  <p><strong>EDIT</strong></p>
  
  <p>Friends,</p>
  
  <p>Actually I have:</p>
  
  <pre><code>HashMap&lt;Long, List&lt;T&gt;&gt; map;
  </code></pre>
  
  <p>and </p>
  
  <pre><code>class T{
     private int a;
     private int b;
     private int c;
     // constructor, getters and setters
  }
  </code></pre>
  
  <p>And size of map may grow to have 10000000 keys and for each key I will have list of size 100-1000.</p>
  
  <p>Will this whole map stay in heap?</p>
  
  <p><strong>EDIT 2</strong></p>
  
  <p>When I loaded map with around 70000 keys, and when I serialized it to file, file was of around 18 MB, so will my map be of 18 MB in heap?</p>