I have a C/C++ program that might be hanging when it runs out of memory. We discovered this by running many copies at the same time. I want to debug the program without co
One way is to write a wrapper around malloc().
static unsigned int requested =0;
void* my_malloc(size_tamount){
if (requested + amount < LIMIT){
requested+=amount;
return malloc(amount);
}
return NULL
}
Your could use a #define to overload your malloc.
As GMan states, you could overload new / delete operators as well (for the C++ case).
Not sure if that's the best way, or what you are looking for