title: Memory Allocation for a Map with a fixed number of insertions
body: <p>I want to insert n elements into a map where n is known ahead of time. I do not want memory allocation at each insertion. I want all memory allocation at the beginning. Is there a way to do this? If so, how? Will writing some sort of memory allocator help?</p>
  
  <p>I ran GMan's code and got the following output. GetMem is printed from a call to "new" and FreeMem is printed from a call to delete. size is the number of bytes requested and ptr is the pointer returned. Clearly, allocation/deallocation is going on during insertion. How do you explain this?</p>
  
  <p>GetMem size 40, ptr 0x8420008<br>
  GetMem size 40, ptr 0x8420038<br>
  GetMem size 120, ptr 0x8420068<br>
  GetMem size 120, ptr 0x84200e8<br>
  FreeMem ptr 0x8420068<br>
  FreeMem ptr 0x8420038<br>
  FreeMem ptr 0x8420008<br>
  Inserting: [0,0]<br>
  GetMem size 40, ptr 0x8420008<br>
  FreeMem ptr 0x8420008<br>
  Inserting: [1,2]<br>
  GetMem size 40, ptr 0x8420008<br>
  FreeMem ptr 0x8420008<br>
  Inserting: [2,4]<br>
  GetMem size 40, ptr 0x8420008<br>
  FreeMem ptr 0x8420008<br>
  Inserting: [3,6]<br>
  GetMem size 40, ptr 0x8420008<br>
  FreeMem ptr 0x8420008<br>
  Inserting: [4,8]<br>
  GetMem size 40, ptr 0x8420008<br>
  FreeMem ptr 0x8420008<br>
  Inserting: [5,10]<br>
  GetMem size 40, ptr 0x8420008<br>
  FreeMem ptr 0x8420008<br>
  GetMem size 40, ptr 0x8420008<br>
  FreeMem ptr 0x8420008<br>
  GetMem size 40, ptr 0x8420008<br>
  FreeMem ptr 0x8420008<br>
  GetMem size 40, ptr 0x8420008<br>
  FreeMem ptr 0x8420008<br>
  GetMem size 40, ptr 0x8420008<br>
  FreeMem ptr 0x8420008<br>
  FreeMem ptr 0x84200e8<br>
  St9bad_alloc  </p>