Can Dispose really free the memory if there are other objects pointing to it?
<p>I have such a code:</p>

<pre><code>    public class A: IDisposable
    {
       public CPlusCode cPlusCode{get;set;}

    public void CallB()
    {
       using(bCode = new B(cPlusCode))
       {
              //do everything in B
       }
    }

   public void Dispose()
   {
         cPlusCode.Dispose();
    }
    }

    public class B: IDisposable
    {
    private CPlusCode cpp;
      public B(CPlusCode cPlus)
    {
    cpp= cPlus;
    }
    public void Dispose()
   {
   cpp.Dispose();
  //dispose everything
    }
    }

   public static void Main()
   {
             for(int i=0; i&lt;100000; i++)
                {
                      var aObject = new A();
                     aObject .CallB();
                }
    }
</code></pre>

<p>The issue is that when I execute <code>Main</code>, and <code>B</code> eats up a lot of memory to instantiate, and from my observation it seems that the memory eaten by the program is not freed up.</p>

<p>Can Dispose really free the memory if there are other objects pointing to it?</p>
