[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

How does "fork()" work?



I have the following code: 

#define BUFFSIZE 32 * 1024 * 1024 

int main() 
{ 
  char *a; 
  a = (char *)malloc(BUFFSIZE); 
  if (fork()) { 
    // Parent 
   free(a); 
  } else { 
    // Child 
  } 
} 

The question is: 
Is there a risk to run out of memory? 

To put it in another way: 
If I allocate 32Mb of memory in the parent process,
then I call fork(), the amount of memory needed for
both parent and child is 64Mb? 


__________________________________________________
Do You Yahoo!?
Get email at your own domain with Yahoo! Mail. 
http://personal.mail.yahoo.com/





[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]