C++符合 STL 的分配器
处理小对象时,有哪些分配器可与 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
您没有说您使用什么编译器,但它可能带有一堆预构建的分配器。这是在带有 gcc 4.2.1 的 Mac 上:
这是还有一个指向 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:
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 开始)。
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).
您需要一个适合您特定需求的分配器。 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.