title: Dispose objects read from BlockingCollection
body: <p>I have to parse a lot of files. So right now I open a file for reading parse the content and write the output on a different location. <strong>That is basically what I need to do but I will like to speed up the process since I am parsing 14000 files.</strong></p>
  
  <p>I improved my algorithm by spliting the work on multiple threads. So I had 1 thread do 25% of the files the next 25 % and so on. </p>
  
  <p>Anyways I believe I will dramatically increase performance and speed if I have:</p>
  
  <ol>
  <li><code>Task 1</code> read files and place the content of the files in  <code>BlockingCollection1</code> (memory)</li>
  <li><code>Task 2</code> will create multiple threads to parse the content of <code>BlockingCollection1</code> and place parsed data in <code>BlockingCollection2</code></li>
  <li><code>Task 3</code> read content from <code>BlockingCollection2</code> and writes it to disk.</li>
  </ol>
  
  <p><strong>The problem that I have now is that I get an out of memory exception.</strong> I will like to let the garbage collector remove items from BlockingCollection1 if they have been used. also I will like to remove items from <code>BlockingCollection2</code> if they have been written to disk. </p>
  
  <p><strong>It is very convenient to use a <code>BlockingCollection&lt;T&gt;</code> since one thread can be adding items to that collection and another thread can be processing those items.</strong> Before I used a linked list but I leaned in this question: <a href="https://stackoverflow.com/a/12519345/637142">https://stackoverflow.com/a/12519345/637142</a> how essay and useful a BlockingCollection can be.  <strong>Anyways how could I solve this problem? Do I have to use a different type of collection such as a stack?</strong></p>