KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
I'm writing an application which needs a lot of memory for caching purposes as I described he here . Now I'm playing around with some malloc / new constructions to figure out how I could realise it. I made a strange observation: #include <stdio.h> #include <stdlib.h> int main(void) { while(1) { char *foo = (char*)malloc(1024);// new char[1024]; if(foo == NULL) { printf("Couldn't alloc\n"); fflush(stdout); return 0; } } return 0; } Why does that printf never be reached? If my system runs out of memory, malloc is said to return NULL, as it is explained here . But I always receive SIGKILL (I'm using linux...).
Tags (comma-separated)
Save Edits
Cancel