title: Program heap size?
body: <p>Is the maximum heap size of a program in C fixed or if I keep malloc-ing it will at some point start to overflow?</p>
  
  <p>Code:</p>
  
  <pre><code> while(connectionOK) //connectionOK is the connection with server which might be forever
   {
      if(userlookup_IDNotFound(userID))
       user_struct* newuser = malloc(getsize(user_struct));
       setupUserAccount(newuser);
   }
  </code></pre>
  
  <p>I am using gcc in ubuntu/ linux if that matters.
  I know something like getrlimit but not sure if it gives heap size. Although it does give the default stack size for one of the options in the input argument.
  Also valgrind is probably a good tool as suggested here <a href="https://stackoverflow.com/questions/9748792/how-to-get-heap-size-of-a-program">how to get Heap size of a program</a> but I want to dynamically print an error message if there is a heap overflow. 
  My understanding was the process address space being allocated by the OS (which is literally allowed to use the whole memory if it wants to) at the beginning of the process creation but I am not sure if it is dynamically given more physical memory once it requests for additional memory.</p>