No, you cannot. You don't have control over the memory deallocation. It is done by the Garbage Collector at some moment of time after some object become
unreachable, and you don't control when exactly it happens. Please see:
http://en.wikipedia.org/wiki/Garbage_collection_%28computer_science%29[
^].
Perhaps the file you read with
ReadAllLines
is just too big. Instead, you can use the class
System.IO.StreamReader
and read the data line by line using
System.IO.StreamReader.ReadLine
:
http://msdn.microsoft.com/en-us/library/system.io.streamreader.aspx[
^],
http://msdn.microsoft.com/en-us/library/system.io.streamreader.readline.aspx[
^].
It would help you to divide a file by smaller chunks and do something with those chunks one at a time.
—SA