简体   繁体   English

符合C ++ STL的分配器

[英]C++ STL-conforming Allocators

What allocators are available out there for use with STL when dealing with small objects. 处理小对象时,可以使用哪些分配器与STL一起使用。 I have already tried playing with pool allocators from Boost, but got no performance improvement (actually, in some cases there was considerable degradation). 我已经尝试过使用Boost中的池分配器,但是并没有提高性能(实际上,在某些情况下性能会大大降低)。

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 : 这是在装有gcc 4.2.1的Mac上:

~$ 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. 这也是指向BitMagic项目页面的链接, 页面讨论如何构建自己的项目。 Also check out small object allocator in the Loki library (and the book too). 还可以在Loki库 (以及本书 )中检出小对象分配器。

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. STL通用分配器最适合多种情况,如果您想要一个新的分配器,则需要分析并了解您的特定要求。 You'll have to be more specific about what container you're going to put these objects in. 您必须更具体地说明将这些对象放入哪个容器。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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