title: Finding a memory leak
body: <p>I have an issue with the following code. I create a memory stream in the GetDB function and the return value is used in a <em>using</em> block. For some unknown reason if I dump my objects I see that the MemoryStream is still around at the end of the Main method. This cause me a massive leak. Any idea how I can clean this buffer ? </p>
  
  <p>I have actually checked that the Dispose method has been called on the MemoryStream  but the object seems to stay around, I have used the diagnostic tools of Visual Studio 2017 for this task.</p>
  
  <pre><code>class Program
  {
      static void Main(string[] args)
      {
          List&lt;CsvProduct&gt; products;
          using (var s = GetDb())
          {
              products = Utf8Json.JsonSerializer.Deserialize&lt;List&lt;CsvProduct&gt;&gt;(s).ToList();
          }
      }
  
      public static Stream GetDb()
      {
          var filepath = Path.Combine("c:/users/tom/Downloads", "productdb.zip");
          using (var archive = ZipFile.OpenRead(filepath))
          {
              var data = archive.Entries.Single(e =&gt; e.FullName == "productdb.json");
              using (var s = data.Open())
              {
                  var ms = new MemoryStream();
                  s.CopyTo(ms);
                  ms.Seek(0, SeekOrigin.Begin);
                  return (Stream)ms;
              }
          }
      }
  }
  </code></pre>