title: C#/SqlServer memory leak
body: <p>I have some problems on my server (Windows Server 2012 r2). Memory is always around 80% of usage and sometimes the CPU too and the hosted apps crash randomly (OutOfMemoryException).</p>
  
  <p>There are about 110 apps on IIS and 95 databases on SQL Server.</p>
  
  <p>The SqlServer machine has ~6500MB of RAM and the IIS machine has ~1400MB of RAM.</p>
  
  <p>There is no reason memory is so high because apps are not constantly requested. I'm wondering if the way I request on sql server is the right way.</p>
  
  <p>This is my function :</p>
  
  <pre><code>public static DataSet SQLServerRequest(string SQL, clsDatabase database)
  {
      SqlConnection myConnection = null;
      DataSet toReturn = new DataSet();
      try
      {
          using (myConnection = new SqlConnection(database.DBConnectionString))
          {
              myConnection.Open();
              using (SqlDataAdapter da = new SqlDataAdapter(SQL, myConnection))
              {
                  da.Fill(toReturn);
              }
          }
          return toReturn;
      }
      catch (Exception ex)
      {
          log.Error(SQL + " / Exception : " + ex.Message);
          return null;
      } 
  }
  </code></pre>
  
  <p>Because I can see on SQL Server :</p>
  
  <p><a href="https://i.stack.imgur.com/omUQh.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/omUQh.png" alt=""></a> </p>
  
  <p>Is it a huge problem? Will moving to Adhoc or LinqSql query help memory going down? Am I looking in the right direction?  </p>