开发者

Disable Stl memory optimization

STL optimizes memory allocation for string objects by providing memory for string objects from a memory开发者_开发知识库 pool kept by the standard library. Is it possible to disable this optimization?

I am using VS 2008


No, you can't. From the C++ reference on string::string:

Except for the copy constructor, an optional final parameter exists for all basic_string constructors, whose type is its Allocator template argument. This parameter influences the memory allocation model to be used for the object. To provide a better readability, and because under no known compiler implementation the memory allocation model for strings (allocator) is affected by its value, it has not been included in the declarations above, but see the basic template member declaration ahead for a more complete declaration.


The following question will help you in understanding how the std::basic_string can be manipulated to be used with various allocators

How do I allocate a std::string on the stack using glibc's string implementation?

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜