自定义C ++分配器的令人信服的例子? [英] Compelling examples of custom C++ allocators?

查看:150
本文介绍了自定义C ++分配器的令人信服的例子?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有什么真正好的原因沟通 std :: allocator 赞成自定义解决方案?你有没有遇到任何情况下,它是绝对必要的正确性,性能,可扩展性等?任何真正聪明的例子?

What are some really good reasons to ditch std::allocator in favor of a custom solution? Have you run across any situations where it was absolutely necessary for correctness, performance, scalability, etc? Any really clever examples?

自定义分配器一直是我没有太多需要的标准库的一个功能。我只是想知道这里的任何人都能提供一些令人信服的例子来证明他们的存在。

Custom allocators have always been a feature of the Standard Library that I haven't had much need for. I was just wondering if anyone here on SO could provide some compelling examples to justify their existence.

推荐答案

=http://stackoverflow.com/questions/657783/how-does-intel-tbbs-scalableallocator-work>在这里,我看到英特尔TBB的自定义STL分配器显着提高多线程应用程序的性能简单通过更改单个

As I mention here, I've seen Intel TBB's custom STL allocator significantly improve performance of a multithreaded app simply by changing a single

std::vector<T>

std::vector<T,tbb::scalable_allocator<T> >

(这是一种快速而方便的方式切换分配器使用TBB的漂亮的线程私有堆;请参阅本文档中的第7页< a>)

(this is a quick and convenient way of switching the allocator to use TBB's nifty thread-private heaps; see page 7 in this document)

这篇关于自定义C ++分配器的令人信服的例子?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆