1

maximum possible malloc

view story
linux-howto

http://ubuntuforums.org – Hi, I have a question which has probable been asked a few times previously on the internet, but I couldn't get a final answer anywhere. My question is, If I run malloc inside an infinite while loop, when will it crash ? Code: #include <stdio.h> #include <malloc.h> int iteration = 0; char* p; int main(void) {  while(1)  {   p = malloc(1024 * 1024 * 1024 * sizeof(char));   if(p == NULL)   {   printf("\nmalloc failed .. Total memory allocated = %dGB",iteration);   break;   }   iteration++;   p (Hardware)