In a context where exceptions are caught, I ran
the fragment:
cerr << "allocating" << endl;
char* arr[100];
for (int jj = 0; jj < 10; ++jj)
{
cerr << "jj = " << jj << endl;
arr[jj] = new char[2000000000];
sleep (30);
}
sleep (10);
for (int jj = 0; jj < 10; ++jj)
delete[] arr[jj];
cerr << "deleted" << endl;
The exception was caught with jj = 1, i.e., on the second allocation.
But on top, I see:
top - 14:08:46 up 5:21, 10 users, load average: 0.04, 0.06, 0.08
Tasks: 158 total, 1 running, 157 sleeping, 0 stopped, 0 zombie
Cpu(s): 2.7%us, 2.0%sy, 0.0%ni, 94.5%id, 0.6%wa, 0.1%hi, 0.1%si,
0.0%st
Mem: 1941908k total, 1231804k used, 710104k free, 138372k buffers
Swap: 3899384k total, 0k used, 3899384k free, 876020k cached
and the "710104k free" suggests that I should have failed on the first
allocation. Furthermore, the allocation did not alter the values
in top (except for a little jitter).
Wherein do I err?
[~]$ uname -a
Linux xxxxx 2.6.18-194.32.1.el5 #1 SMP Wed Jan 5 17:53:09 EST 2011 i686
i686 i386 GNU/Linux
Thanks,
Mike.