title: Pool memory allocation in a priority queue
body: <p>I am writing an event based simulator, in which each event calls a processing function (node) that can generate new events, and so on.
  A timestamp is associated to each events and they need to be processed in the order of increasing time (but the events are not necessarily created in that order). To this end, I use a simple <code>priority_queue&lt;Event*&gt;</code>, where Event is a class containing a pointer to the processing node that must be called and the timestamp.</p>
  
  <p>So, everything works fine, but I get millions of events allocated and deallocated per second and this is clearly what is limiting the speed of my simulator (roughly 30% of the execution time is taken by memory allocation and deallocation of Event objects).</p>
  
  <p>I found this question:
  <a href="https://stackoverflow.com/questions/1250983/object-pool-vs-dynamic-allocation">Object pool vs. dynamic allocation</a> and it seems like I could very much benefit from an object pool. Although I have seen that Boost is offering some way to do that, I am not sure to understand if this is practical for implementing a pool in a <code>priority_queue</code>. I am really lost when it comes to custom memory allocation.</p>
  
  <p><strong>So my question is:</strong> would it be practical / beneficial to use an object pool for my <code>priority_queue</code>, and if yes, is there a simple way to do it, with maybe some code example (or at least a starting point), preferably without immediately relying on Boost in a first time?</p>
  
  <p>Actually some refs to understand how pool allocation works would also be welcome!</p>
  
  <p>Thanks.</p>