Intel® C++ Compiler
Community support and assistance for creating C++ code that runs on platforms based on Intel® processors.

16GB Limit for a single 1D array

jimwon
Beginner
404 Views
My computer has 64-bit OS, 64-bit CPU and over 30GB RAM, but my code could not access more than 16GB. I am wondering if there is a 16GB limit for a single 1D array. Here is a simple test case.

__int64 i, n;
double *a=0;
n = 3000000000; // 3E+09
a = new double; // allocate ~24GB.
for (i=0; i LT n; i++) a = 1.0 * i;
.....
delete[] a;
....

Are there any potential problems in this code segment?

Thank you. Jim
0 Kudos
3 Replies
xorpd
Beginner
404 Views
The line where you set n to -1294967296 is suspect.
0 Kudos
jimwon
Beginner
404 Views
I am not sure where you got n = -1294967296. Without using __int64, there is a clear limit of 16GB because the max value of an int = 2G. I set __int64 n = 3G on purpose here.
0 Kudos
levicki
Valued Contributor I
404 Views

Xorpd tried to say that 3,000,000,000 = 0xB2D05E00. If passed as 32-bit int that is a -1294967296.

I suppose new allocates from heap. Perhaps there is a limit on heap size (the limit in CRT) for an application. Write replacement for a new and delete operators using VirtualAlloc and try again. If it allocates 24GB then it is a CRT (heap) limit, if not, then it is a compiler limit (it treats n as int).

0 Kudos
Reply