- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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
__int64 i, n;
double *a=0;
n = 3000000000; // 3E+09
a = new double
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
Link Copied
3 Replies
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
The line where you set n to -1294967296 is suspect.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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).
Reply
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page