I'm trying to figure out when the memory is allocated for my program. Here is my code
#include <unistd.h>
#include <iostream>
#include <cstdlib>
using namespace std;
int main()
{
cout << "when the memory is allocated?";
cout << endl;
cout.flush();
int * p = new int[250000000];
sleep(3);
cout << "address: " << p;
cout << endl;
cout.flush();
sleep(3);
cout << "value" << p[0];
cout << endl;
cout.flush();
sleep(10);
cout << "ending";
cout << endl;
return 0;
}
I kept track of it with Activity Monitor on my mac.
I found I didn't get the GB memory I applied. When the memory will be actually allocated for new int[250000000]
in C++?