问题
I have an ASP.NET web app and it's using 5GB memory running on 64bit Windows 7 machine with 8GB memory without any problem.
However, when I create a new C# console application on the same machine and reuse the same components the web app uses, the console app runs out of memory at about 1.6GB (by looking at System.Environment.WorkingSet and System.Diagnostics.Process.GetCurrentProcess().WorkingSet64). There are still plenty of physical memory left. It repros on 2 different machines.
Both web app and console app use ThreadPool.QueueUserWorkItem to start a background thread to load the large amount of data. The exception happens at the background thread.
I wonder if there is any default memory limit setting on console app or ThreadPool. What debug variables I can look at to see this limit?
回答1:
This is simple. By default my Visual Studio 2010 creates x86 target. Changing it to x64 solves the problem.
来源:https://stackoverflow.com/questions/9475355/64bit-console-app-threadpool-out-of-memory