Recently I wrote a program which loads some CSV files in to DataTables and do some processing. These files are in large size and have nearly 1 million rows. When I load first file in to data table it works fine. But then I load the second file I get a “Out of Memory exception” even though first I make the previously loaded datatable to null. After searching for hours I found the following solution which solved my issue.
if you make the datatable null what happens is it frees the Datatable from the rows and columns. But actually those rows and columns retained in the memory and those are not ready for the garbage collector. But when you call Clear() all the memory will be cleared.
Hope this helps.
Happy Coding !!!