title: Memory not getting freed up in Asp.Net core api
body: <p>I have an issue where the memory is not getting freed up in my .NET Core Web API. All I am doing is simply returning a string from a static class.</p>
  
  <p>API:</p>
  
  <pre><code>[HttpGet]
  public string Get()
  {
      return A.get();
  }
  
  public static class A
  {
      public static string get()
      {
          return "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa";
      }
  }
  </code></pre>
  
  <p>Client:</p>
  
  <pre><code>HttpClient hc = new HttpClient();
  for(int i=0;i&lt;100000;i++)
  {
      //var v = hc.GetAsync("http://localhost:52425/api/values").result;
      hc.GetStringAsync("http://localhost:52425/api/values");
      if(i%1000 == 0)
      {
          Thread.Sleep(10000);
          Console.WriteLine("Sleeping-----------" + i);
      }
  }
  </code></pre>
  
  <p>I have tried returning the string directly from the action method without the static class. I have also tried to call the API from the client in synchronous fashion rather than async. None of these made any difference.</p>
  
  <p>This screenshot shows that where GC is called once but does not help clear up the memory.</p>
  
  <p><a href="https://i.stack.imgur.com/BjgbI.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/BjgbI.png" alt="memory from diagnostics"></a></p>
  
  <p>Here are the diagnostics after upgrading to 2.0 and disabling telemetry info:</p>
  
  <p><a href="https://i.stack.imgur.com/clOsA.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/clOsA.png" alt="enter image description here"></a></p>