title: C# Parallel.ForEach() memory usage keeps growing
body: <pre><code>public string SavePath { get; set; } = @"I:\files\";
  
  public void DownloadList(List&lt;string&gt; list)
  {
      var rest = ExcludeDownloaded(list);
      var result = Parallel.ForEach(rest, link=&gt;
      {
          Download(link);
      });
  }
  
  private void Download(string link)
  {
      using(var net = new System.Net.WebClient())
      {
          var data = net.DownloadData(link);
  
          var fileName = code to generate unique fileName;
          if (File.Exists(fileName))
              return;
  
          File.WriteAllBytes(fileName, data);
      }
  }
  
  var downloader = new DownloaderService();
  var links = downloader.GetLinks();
  downloader.DownloadList(links);
  </code></pre>
  
  <p>I observed the usage of RAM for the project keeps growing
  <a href="https://i.stack.imgur.com/KR3LX.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/KR3LX.png" alt="enter image description here"></a></p>
  
  <p>I guess there is something wrong on the Parallel.ForEach(), but I cannot figure it out.</p>
  
  <p>Is there the memory leak, or what is happening?</p>
  
  <hr>
  
  <p>Update 1</p>
  
  <p>After changed to the new code</p>
  
  <pre><code>private void Download(string link)
  {
      using(var net = new System.Net.WebClient())
      {
          var fileName = code to generate unique fileName;
          if (File.Exists(fileName))
              return;
          var data = net.DownloadFile(link, fileName);
          Track theTrack = new Track(fileName);
          theTrack.Title = GetCDName();
          theTrack.Save();
      }
  }
  </code></pre>
  
  <p><a href="https://i.stack.imgur.com/YtZ2Z.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/YtZ2Z.png" alt="enter image description here"></a></p>
  
  <p>I still observed increasing memory use after keeping running for 9 hours, it is much slowly growing usage though.</p>
  
  <p>Just wondering, is it because that I didn't free the memory use of theTrack file?</p>
  
  <p>Btw, I use <a href="https://www.nuget.org/packages/z440.atl.core/3.3.0" rel="nofollow noreferrer">ALT package</a> for update file metadata, unfortunately, it doesn't implement IDisposable interface.</p>