I am using Parallel.ForEach to do my job but got "Out of Memory Exception".
Parallel.ForEach(flist, (item) =>
{
string f1 = item.Split('|')[0];
string f2 = item.Split('|')[1];
a = File.ReadAllText(f1);
b = File.ReadAllText(f2);
Consume(a, b);
});
flist
's size is 351, a
and b
are string, each of them has 20kb size. At a certain time, the system memory blown up.
Consume return a string list, usually around 1000 strings in each iteration.
How to deal with it?