C++符合 STL 的分配器

发布于 2024-08-27 06:05:48 字数 87 浏览 3 评论 0原文

处理小对象时,有哪些分配器可与 STL 一起使用。我已经尝试过使用 Boost 的池分配器,但性能没有得到改善(实际上,在某些情况下,性能出现了相当大的下降)。

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

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

稀香 2024-09-03 06:05:48

您没有说您使用什么编译器,但它可能带有一堆预构建的分配器。这是在带有 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

这是还有一个指向 BitMagic 项目页面的链接,该页面讨论如何构建您自己的项目。另请查看 Loki 库 中的小对象分配器(以及 也)。

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

萝莉病 2024-09-03 06:05:48

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

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

偷得浮生 2024-09-03 06:05:48

您需要一个适合您特定需求的分配器。 STL 通用分配器最适合各种情况,如果您想要一个新的分配器,您将需要分析并了解您的具体要求。您必须更具体地说明要将这些对象放入哪个容器。

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文