Reputation: 195
I am compiling an application with the /LARGEADRESSAWARE switch set, but when running and looking at the taskmanager, the application allocates max. ca. 2.5GB then it fails with memory allocation errors. Is this correct behaviour?
In the taskmanager i should see the full 4GB. MSDN states "4 GB with IMAGE_FILE_LARGE_ADDRESS_AWARE set" for a 32 Bit process running under a 64 Bit OS here
This is the linker command line (with some paths stripped)
/OUT:"xxx.exe" /MANIFEST /LTCG /NXCOMPAT /PDB:"xxx.pdb" /DYNAMICBASE /LARGEADDRESSAWARE /DEBUG /MACHINE:X86 /SAFESEH:NO /PGD:"xxx.pgd" /SUBSYSTEM:WINDOWS /MANIFESTUAC:"level='asInvoker' uiAccess='false'" /ManifestFile:"xxx.manifest" /ERRORREPORT:PROMPT /NOLOGO /LIBPATH:"xxx" /TLBID:1
Upvotes: 0
Views: 237
Reputation: 59410
Even checking the commit size in Task Manager cannot reveal all possible sources of an OutOfMemoryException, although it was a good guess by Hans Passant.
Here are some examples were it does not work:
run an application and reserve 3.5 GB of memory instead of committing it. Very likely that you get an OutOfMemoryException as well, but the commit size column in Task Manager will not help you. In that case you'll need a tool to display the Reserved Size, e.g. VMMap or Process Explorer (use "virtual size" there, which is reserved + committed)
write the following very simple .NET program:
class Program
{
static void Main(string[] args)
{
byte[] b = new byte[2*1024*1024*1000];
}
}
In that case, you neither have committed nor reserved memory that could help you identify the source of the OutOfMemoryException. Here we have a problem of virtual memory fragmentation.
Some debuggers can help you analyzing OutOfMemoryExceptions.
Screenshot of a program that reserved 2 GB and has only 12 MB committed:
Upvotes: 1
Reputation: 195
Hans Passant gave a useful answer in his comment. I did not check 'Commit Size', i checked the private bytes and commit size in the task manager shows some 3.5GB memory usage when allocations begin to fail. Thanks!
Upvotes: 2