Hi,
GCC problems solved. Many thanks for your help.
Test app shows answers:
Mandriva 2009.1. 2gb RAM 4gb swap. overcommit_ratio=50 (presumably should
die at 300gb + but doesnt).
/proc/sys/vm/overcommit_memory is reset to 0 on boot so man malloc solution
of
cat 2 > /proc/sys/vm/overcommit_memory doesnt work (probably would if placed
in some boot script
but thats a Mandriva issue).
#include <string.h>
#include <iostream>
using namespace std;
int main()
{
//long long llSize = 1000000*1024*1024LL; // 1,048,576,000,000 bytes.
Succeeds!
long long llSize = 0xFFFFFFFFFFFFFFFFLL; // This generates an exception
try
{
char * pMem = new char[llSize];
cout << "new worked" << endl;
memset(pMem, 1, llSize); // Seems to work
pMem[llSize - 1] = 2; // Seems to work
if(pMem)
delete pMem; // No problems
}
catch(...) // This works on gcc 4.3.2 (needs #include <new> if
std::bad_alloc caught)
{
cout << "catch(...)" << endl;
return 1;
}
return 0;
}
Once again, many thanks for your help.
Jan