Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

C++ Application crashes once it memory usage reaches 1.5 GB [closed]

Tags:

c++

windows

We have a C++ application running on Windows 32 bit system. It crashes once the memory usage reaches 1.5 GB. What we are unable to understand is why it's crashing at 1.5 GB limit and not at 2 GB limit (the virtual address space and windows 32 bit architecture limit)?

Other details:- Total memory available : 4GB

Operating System : Windows XP

1.5 GB is the memory used by just this one process.

Regards,

Sachin

like image 202
sachin Avatar asked Apr 16 '11 06:04

sachin


1 Answers

This is perfectly normal under 32bit Windows.

Unless you have the /3gb switch activated, you have a total address space of 2GB. However, that's minus the mapped executable and at least half a dozen DLL and NLS files (for "hello world" -- a real application would probably have more like a dozen or two dozen of them).

Since they are not optimally placed, you lose about half a gigabyte of addres space. The heap will not grow "into" that region, and thus allocating more than 1.5GB will fail.

Here is what the address space of a "typical program" looks like:

enter image description here

Note how very skillfully one DLL is placed at about 1/3 of the address space, effectively "cutting off" a third of the memory that you can use.

like image 147
Damon Avatar answered Sep 22 '22 12:09

Damon