I'm using c++ builder 10.2 Tokyo on windows 10 with 16 GB RAM. If I run
uint64_t FreeMBs()
{
MEMORYSTATUSEX status;
status.dwLength = sizeof(status);
GlobalMemoryStatusEx(&status);
return status.ullAvailPhys / (1024 * 1024);
}
Mem0=FreeMBs();
std::vector<int64_t> v;
v.resize(1000000000); // 1 billion
Mem1=FreeMBs();
Mem0-Mem1 is around 8 GB.
If, instead of the above, I run
Mem0=FreeMBs();
int64_t v=new int64_t[1000000000};
Mem1=FreeMBs();
then Mem0-Mem1 is around zero. If I use malloc to reserve space for the array Mem1 is still more or less unchanged from Mem0. I tried setting v[1000000000-1]=0 to see if that triggered something but it didn't.
Why doesn't it account for the array?