Address space for a 32-bit Windows program (Windows is implied by C++-CLI) running on a 64-bit operating system is either
- 2 GB by default
- 4 GB if linked with
/LARGEADDRESSAWARE
. This flag can also be added later byeditbin
.
Your problem is address space fragmentation. Just because you've only allocated, say 100MB, doesn't mean that you can allocate another 1.9GB chunk in a 2GB address space. Your new allocation needs to have contiguous addresses.
If, for example, a DLL used by your non-LAA process had a load-address at 0x40000000
, then you could allocate a 1GB block below it, or an almost-1GB block above it, but you could never allocate a single block larger than 1GB.
The easiest solution is to compile as 64-bit. Even though the address space will still be fragmented, the open spaces between allocations will be much larger and not cause you problems.