Memory management in C#
<p>Good afternoon,</p>

<p>I have some text files containing a list of (2-gram, count) pairs collected by analysing a corpus of newspaper articles which I need to load into memory when I start a given application I am developing. To store those pairs, I am using a structure like the following one:</p>

<pre><code>private static Dictionary&lt;String, Int64&gt;[] ListaDigramas = new Dictionary&lt;String, Int64&gt;[27];
</code></pre>

<p>The ideia of having an array of dictionaries is due to efficiency questions, since I read somewhere that a long dictionary has a negative impact on performance. That said, every 2-gram goes into the dictionary that corresponds to it's first character's ASCII code minus 97 (or 26 if the first character is not a character in the range from 'a' to 'z').</p>

<p>When I load the (2-gram, count) pairs into memory, the application takes an overall 800Mb of RAM, and stays like this until I use a program called Memory Cleaner to free up memory. After this, the memory taken by the program goes down to the range 7Mb-100Mb, without losing functionality (I think).</p>

<p>Is there any way I can free up memory this way but without using an external application? I tried to use <code>GC.Collect()</code> but it doesn't work in this case.</p>

<p>Thank you very much.</p>
