Enlarge heapsize c++

Björn Hallström picture Björn Hallström · Apr 1, 2014 · Viewed 9.2k times · Source

is there some way to enlarge the heapsize of a c++ program? In android you can easily do that by declaring it as large in the manifestfile.

I encountered this problem when I tried to allocate one billion array-elements on the heap.

int main() {
 int size = 1000000000;
 int* nmbr = new int[size];
 return 0;
}

Answer

Christian Hackl picture Christian Hackl · Apr 1, 2014

C++ itself doesn't know what the "heap" is. This is an implementation issue, so you have to look into your compiler's documentation. Here's what a Google search for "MSVC heap size flag" found:

http://msdn.microsoft.com/en-us/library/f90ybzkh.aspx

Quoting from the MSDN page:

The /HEAP option sets the size of the heap in bytes. This option is only for use when building an .exe file.