heap memory allocation limits - win7 64 bit

heap memory allocation limits - win7 64 bit

Good evening

Is there a limitation for allocating memory on the heap?

build is a 64bit exe

OS is WIN7 64.

physical memory is 12GB

Trying to get a chunk of memory larger than 2 GB always

returns an error.

kind regards




8 posts / 0 new
Last post
For more complete information about compiler optimizations, see our Optimization Notice.

Probably this is your process maximum allocatable heap size.

Try to run Sysinternals TestLimit64.exe.tool and observe how much memory it was able to allocate.


Can you show the statement that fails.

#include "stdafx.h"
int _tmain(int argc, _TCHAR* argv[])


	double* array = NULL;

	__int64 N = 1000000000ll; // 8GB

	array = new double[N];




		printf("Not allocatedm");

	return 0;


The above works (on my Win7 system) provided: a) 64-bit build, b) page file is large enough

Jim Dempsey


Theoretical limit of virtual memory process address space on Windows 64bit is 8TB.

>>Theoretical limit of virtual memory process address space on Windows 64bit is 8TB.
At issue is not the Virtual Address space. What is at issue here is mapping the allocation to the page file. On Windows you can fix the page file size and/or limit expansion and/or have a space limitation on the drive(s) selecting for the page file. The heap, when insufficient memory is in the current heap, will request a blob of Virtual Memory be mapped to the page file (it may or may not do other things like wipe). This assigns (maps) portions of the process Virtual Memory to page file pages. If necessary, and permitted, and if sufficient disk space is available, the page file is expanded. If the expansion cannot fulfill the request, you get an error.

Jim Dempsey


Thanks for the explanation.

As a side note. Other O/Ss may implement a lazy page file mapping/expansion. What happens here is an overly large allocation will succeed (non NULL pointer returned), however, during use later, eventually you get a page fault when the page file cannot be extended. IMO the error should occur on the allocation not on the use.

Additional note. Although the Virtual Memory to Page File mapping (reservation) is performed on allocation, it need not be associated with physical RAM until first touch. IOW on NUMA system the physical memory mapping occurs on first touch.

Jim Dempsey



Login to leave a comment.