title: Managed Memory: Object count higher than expected
body: <p>I don't have much experience with the diagnostic tools within Visual Studio and it's something I'm using to further myself with the IDE.</p>
  
  <p>In my application I've created my own class to help out with anything sql related, this class currently creates one SqlCommand and SqlConnection within a constructor , then it adds the SqlConnection to the SqlCommands.Connection and then stores both objects into their own properties. I'm persisting this class across post backs and when ever a page needs the command object I place</p>
  
  <pre><code>SqlHelper Instance;
  </code></pre>
  
  <p>At the top of the cs file, and then:</p>
  
  <pre><code>Page_Load:
  
  if (Session["SQLH"] == null)
  {
      Instance = new SqlHelper();
      Session["SQLH"] = Instance;
  }
  else
      Instance = (SqlHelper)Session["SQLH"];
  </code></pre>
  
  <p>then I simply do:</p>
  
  <pre><code>using(SqlCommand cmd = Instance.cmd)
  {
    // Do Stuff
  }
  </code></pre>
  
  <p>(I don't want to hear anything like "blah blah garbage collection is very efficient, do this, do that")</p>
  
  <p>Okay so now the <strong>question</strong>, when debugging my application I'm taking snapsots of the memory usage of my application and if I search for SqlCommand the count shows 8? If I search for SqlHelper (My class) the count shows 1, am I reading the results wrong or..?</p>
  
  <p>I am using <strong>using</strong> statements, and I am closing my connections manually.</p>
  
  <p>Snap Shot example:</p>
  
  <p>Managed Memory:
     Object Type: SqlCommand<br>
           Count: 8<br>
            Size: xBytes<br>
  Inclusive Size: yBytes</p>
  
  <p>If I select the objecttype it shows 7 reference counts of "DbCommandDefinition"?? and 1 count of SqlHelper.</p>