title: malloc memory allocation scheme in C
body: <p>I was experimenting with malloc in C and I have observed that malloc is wasting some space after some memory has been allocated. Below is the piece of code I used to test malloc</p>
  
  <pre><code>#include &lt;stdlib.h&gt;
  #include &lt;string.h&gt;
  
  int main(){
      char* a;
      char* b;
      a=malloc(2*sizeof(char));
      b=malloc(2*sizeof(char));
      memset(a,9,2);
      memset(b,9,2);
      return 0;
  }
  </code></pre>
  
  <p>In the right-middle of the following picture(open the image in a new tab for clarity) you can see the memory contents;0x804b008 is the address pointed by variable 'a' and 0x804b018 is the memory pointed by variable 'b'. what is happening to memory between from 0x804b00a 0x804b017? The thing is even if I try to allocate <code>3*sizeof(char)</code> instead of <code>2*sizeof(char)</code> bytes of memory the memory layout is the same! So, is there something I am missing?</p>
  
  <p><img src="https://i.stack.imgur.com/jb72D.png" alt="gdb interface"></p>