简体   繁体   中英

C++ STL-conforming Allocators

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

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

Microsoft Visual C ++标准库实现为基于节点的容器提供了几个专有的分配器 (至少在即将发布的Visual Studio 2010中)。

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM