I have a C# app that must link with a 32-bit library and also needs to use the maximum amount of memory possible (imaging app); we run the app on XP64 desktops, thus we are using WOW64, targeting builds in Visual Studio for x86 (and doing an editbin /largeaddressaware
post-build). We're encountering a few problems:
In the Visual Studio built-in debugger, we can only ever use 2gb of memory (~1.5gb to the app, plus overhead)
Running from the command line, the app can see 3gb of memory, but Microsoft documents would seem to say we should see 4gb.
Can anyone tell me how to get a WOW64 C# app to see the full 4gb that the platform should be able to give it?
Also, can anyone tell me how to get the Visual Studio (VS 2008, otherwise known as VS90) debugger to obey the /largeaddressaware
bit and stop limiting the app memory to 2gb?
I see the same behavior in VS80 and VS90; also no difference between .NET Framework 3.5, 3.0, and 2.0. Here's a trivial C# program that illustrates the problems; build for x86, editbin /largeaddressaware
, then run in built-in debugger versus run from command line to see the difference in memory available to C#.
namespace MemoryAllocTest
{
class Program
{
static void Main(string[] args)
{
const int allocSize = 1024 * 1024;
List<byte[]> myMem = new List<byte[]>();
UInt64 totalAlloc = 0;
while (true)
{
myMem.Add(new byte[allocSize]);
totalAlloc += allocSize;
Console.WriteLine("{0} allocs: {1}MB total",
myMem.Count, totalAlloc / (1024 * 1024));
}
}
}
}