Excessive memory allocation makes ubuntu unresponsive
Whenever a program on my machine uses lots of memory the machine will occasionally become unresponsive for 10-20 seconds at a time. I can move the mouse around but nothing else responds. This happens with chrome all the time. Am I the only one seeing this or is this a common issue? If it's just me it's probably a configuration issue.
Worse, I've accidentally during development run programs that allocate an unbounded amount of memory and this makes the machine terminally unresponsive. Not even the mouse responds. The only way to bring it back is to turn it on and off physically. The program below reproduces the issue consistently. Even though it's clearly a bad program I'd expect the OS to provide at least a minimum of protection here, for some reason mine doesn't.
#include <stdlib.h>
int main(int argc, char *argv[]) {
unsigned long long size = 0;
for (size = 4; 1; size *= 2) {
malloc(size);
}
}
Question information
- Language:
- English Edit question
- Status:
- Answered
- For:
- Ubuntu Edit question
- Assignee:
- No assignee Edit question
- Last query:
- Last reply:
Can you help with this problem?
Provide an answer of your own, or ask Christian Plesner Hansen for more information if necessary.