Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Enlarge heapsize c++

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;
}
like image 942
Björn Hallström Avatar asked Oct 16 '25 08:10

Björn Hallström


1 Answers

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.

like image 84
Christian Hackl Avatar answered Oct 17 '25 21:10

Christian Hackl