Most likely, this is not about RAM as it is, so increasing your RAM or even compiling and running your code on 64 bit machine will not have a positive effect, in this case.
I think this is due to the fact that .NET collections are limited to a maximum size of 2GB RAM (no difference is 32 or 64 bit).
To solve this problem, split your list into smaller chunks and most likely your problem will go away.
Only one possible solution:
foreach (var result in query) { .... if(logFilePathFileName.Count %1000 ==0) { Console.WriteLine(temp+"."+logFilePathFileName.Count);
EDIT
If you need a snippet request , you can use Skip(...) and Take(...)
Just an explanatory example:
var fisrt1000 = query.Skip(0).Take(1000); var second1000 = query.Skip(1000).Take(1000);
... etc.
Naturally put it on your iteration and parameterize it based on the limitations of the data you know or need.
Tigran
source share