YetiSim Blog

Blogs about simulation and developing YetiSim.

The scalable_allocator: Reducing Implementation Work

I decided last night that I needed to implement a memory pool for YetiSim to boost efficiency. What I did not know, was that Threading Building Blocks already hid some of the details of pooling within the scalable_allocator. A response on the TBB forum indicated that the scalable_allocator was already capable of pooling, and that perhaps I did not need to implement my own classes for this purpose.

I already knew about the scalable_allocator, but there were some details that I did not know. First, that it implemented any form of pooling at all. You can learn more from this link. Another point that I did not know, was that it could be used as the allocator within an STL container. I knew that the cache_aligned_allocator could do this, but I was unaware that the scalable_allocator was also usable. This brings up a question: Does the cache_aligned_allocator pool memory in the same manner as the scalable_allocator? I would imagine it does, but I will have to investigate to find out.

This greatly simplifies the design of my MemoryManager class, in fact the first implementation of the class will merely wrap create and delete calls. At a later point, other magic may be done, however for now if the scalable_allocator works as promised, my memory management will be very simple. I still feel that it is good design to separate out memory management concerns, in case adjustments are required later.


Posted by AJ Guillon  (December 7, 2007)

Leave a Reply