title: What are the contents of the memory just allocated by `malloc()`?
body: <p>I was curious about what exactly a pointer holds, after <code>malloc()</code> was used to allocate memory space? The manpage tells me that <code>calloc()</code> initializes the allocated memory space with zero.</p>
  
  <blockquote>
    <p>The  malloc()  function allocates size bytes and returns a pointer to the allocated memory.  <strong>The memory is not initialized</strong>.  If size is 0, then malloc() returns  either  NULL, or a unique pointer value that can later be successfully passed to free().</p>
  </blockquote>
  
  <p>and</p>
  
  <blockquote>
    <p>The calloc() function allocates memory for an array of nmemb elements of size bytes each
           and  returns a pointer to the allocated memory.  <strong>The memory is set to zero</strong>.  If nmemb or
           size is 0, then calloc() returns either NULL, or a unique pointer value that  can  later
           be successfully passed to free().</p>
  </blockquote>
  
  <p>I created a really short example program in C, to C(haha) for myself:</p>
  
  <pre><code>int main() {
      char *dynamic_chars;
      unsigned amount;
      printf("how much bytes you want to allocate?\n");
      scanf("%d", &amp;amount);
  
      dynamic_chars = (char*)malloc(amount*sizeof(char));
      printf("allocated:\n%s\n", dynamic_chars);
  
      free(dynamic_chars);
      return 0;
  </code></pre>
  
  <p>}</p>
  
  <p>However when executing this code, it just outputs nothing. If I initialize the memory my self for example initializing every single byte with <code>0xFFFF</code> using a loop, then the program shows me exactly what I expect. The memory space actually exists, since I wont get an error claiming that I am trying to access uninitialized variables or so. </p>
  
  <p>Since memory space is usually not deleted but marked as rewritable I wonder if by executing my program, shouldn't I be able to see random previously used Bytes of memory? But I wont see anything, so I am really confused about how exactly <code>malloc()</code> works.</p>
  
  <h1>EDIT1</h1>
  
  <p>Another thing about <code>malloc()</code> or maybe memory usage in general, that is interesting about my program:
  If I use <code>calloc()</code>, to allocate memory, I can trace the actual memory usage of my program, by e.g. monitoring it. For example, if I tell my program, to allocate 1.000.000.000 Bytes of memory per <code>calloc()</code> I will see the following in my System monitor:
  <a href="https://i.stack.imgur.com/sQMHq.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/sQMHq.png" alt="Memory consumption when using &lt;code&gt;calloc()&lt;/code&gt;"></a></p>
  
  <p>As you can probably imagine, when using <code>malloc()</code>, I wont see nothing. I understand, that just by allocating memory, I am not really using it at that time, but I am still confused about why my operating system (unix derivate) won't recognize it as being used. Since <code>malloc()</code> just like <code>calloc()</code> returns a physical address to a memory location I don't get, how this memory area seems to be not actually reserved by the OS. Elsewise I could see it in the System Monitor right? 
  If I should rather post this as a new question, please let me know. But I think since the question is still about how <code>malloc()</code> works it fits in here.</p>