title: C# Too Much Memory Usage
body: <p>I have a process going with multiple steps defied. (Let's say generic implementation of a strategy pattern) where all steps are passing a common ProcessParameter object around. (read/write to it)</p>
  
  <p>This ProcessParameter is an object having many arrays and collections. Example:</p>
  
  <pre><code>class ProcessParameter() {
     public List&lt;int&gt; NumbersAllStepsNeed {get; set;}
     public List&lt;int&gt; OhterNumbersAllStepsNeed {get; set;}
     public List&lt;double&gt; SomeOtherData {get; set;}
     public List&lt;string&gt; NeedThisToo {get; set;}
     ...
  }
  </code></pre>
  
  <p>Once the steps finished, I'd like to make sure the memory is freed and not hang around, because this can have a big memory footprint and other processes need to run too.</p>
  
  <p>Do I do that by running:</p>
  
  <pre><code>pParams.NumbersAllStepsNeed = null;
  pParams.OhterNumbersAllStepsNeed = null;
  pParams.SomeOtherData = null;
  ...
  </code></pre>
  
  <p>or should ProcessParameter implement IDosposable, and Dispose method would do that, and then I just need to use <code>pParams.Dispose()</code> (or wrap it in using block)</p>
  
  <p>What is the best and most elegant way to clean the memory footprint of the used data of one process running?</p>
  
  <p>Does having arrays instead of lists change anything? Or Mixed?
  The actual param type I need is collections/array of custom objects.</p>
  
  <p>Am I looking in the right direction?</p>
  
  <p><strong>UPDATE</strong></p>
  
  <p>Great questions! Thanks for the comments!
  I used to have this process running as a single run and I could see memory usage go very high and then gradually down to "normal".</p>
  
  <p>The problem came when I started chaining this processes on top of each other with different stating parameters. That is when memory went unreasonably high, so I want to include a cleaning step between two processes and looking for best way to do that.</p>
  
  <p>There is a DB, this params is a sort of "cache" to speed up things.</p>
  
  <p>Good point on IDisposable, I do not keep unmanaged resources in the params object.</p>