tags:

views:

158

answers:

3

What allocators are available out there for use with STL when dealing with small objects. I have already tried playing with pool allocators from Boost, but got no performance improvement (actually, in some cases there was considerable degradation).

+1  A: 

The Microsoft Visual C++ standard library implementation provides several proprietary allocators for node-based containers (at least as of the soon-to-be-release Visual Studio 2010).

James McNellis
+2  A: 

You didn't say what compiler you use, but it probably comes with a bunch of pre-built allocators. This is on a Mac with gcc 4.2.1:

~$ find /usr/include/c++/4.2.1/ -name "*allocator*"
/usr/include/c++/4.2.1/bits/allocator.h
/usr/include/c++/4.2.1/ext/array_allocator.h
/usr/include/c++/4.2.1/ext/bitmap_allocator.h
/usr/include/c++/4.2.1/ext/debug_allocator.h
/usr/include/c++/4.2.1/ext/malloc_allocator.h
/usr/include/c++/4.2.1/ext/mt_allocator.h
/usr/include/c++/4.2.1/ext/new_allocator.h
/usr/include/c++/4.2.1/ext/pool_allocator.h
/usr/include/c++/4.2.1/ext/throw_allocator.h

Here's also a link to BitMagic project page that talks about how to build your own. Also check out small object allocator in the Loki library (and the book too).

Nikolai N Fetissov
A: 

You need an allocator that's right for your specific needs. The STL generic allocator is the best for the huge variety of circumstances, and if you want a new allocator, you will need to profile and understand your specific requirements. You'll have to be more specific about what container you're going to put these objects in.

DeadMG