Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

C++ STL-conforming Allocators

Tags:

c++

stl

allocator

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).

like image 765
myahya Avatar asked Apr 03 '10 20:04

myahya


2 Answers

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).

like image 74
Nikolai Fetissov Avatar answered Sep 25 '22 13:09

Nikolai Fetissov


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).

like image 34
James McNellis Avatar answered Sep 21 '22 13:09

James McNellis