What is memory space occupied for reference and object
<p>What happen at background(in case of memory) when I declare variable  and then create object for that variable . Is reference variable store anywhere and in which format and how this variable points to the memory on heap. Please clarify below doubts in the comments.</p>

<p>For example</p>

<pre><code>ClassA instance;       // Where this variable store and how much memory occupies
instance=new ClassA(); //How instance variable points to memory
</code></pre>

<p><strong>EDIT</strong></p>

<p>What will effect on my program memory if my program contains so many unused variable.</p>
