title: First allocation using dlmalloc
body: <p>I am reading about Doug Lea's malloc implementation(dlmalloc) from <a href="http://gee.cs.oswego.edu/dl/html/malloc.html" rel="nofollow noreferrer">http://gee.cs.oswego.edu/dl/html/malloc.html</a> .</p>
  
  <p>I understood that chunks contain size &amp; other information along with memory space. The chunks are maintained in bins(in the form of linked list), according to size.</p>
  
  <p>Whenever malloc is called with 'n' bytes, it looks for a chunk in suitable bin(which stores 'n' sized chunks) &amp; if found, the chunk is removed from the bin.</p>
  
  <p>And whenever free is called it inserts the block to be freed as a chunk in suitable bin.</p>
  
  <p>So, my questions are - </p>
  
  <ol>
  <li><p>At the beginning, when all the heap memory is unallocated/free, all bins should be empty, right?(since only free function inserts chunks in bins)</p></li>
  <li><p>If this is the case, how(from where) first memory block will be allocated?</p></li>
  <li><p>Can someone explain in detail about the 'designated victim'(dv) chunk &amp; top chunk? What will be dv chunk at the time of first allocation?</p></li>
  </ol>