什么时候应该更喜欢对象池而不是动态分配的对象?
我需要每秒创建和销毁数千个对象。它本身足以决定支持对象池吗?
谢谢。
最佳答案
是的,这足以决定支持对象池。
引用 Boost 文档
When should I use Pool?
Pools are generally used when there is a lot of allocation and deallocation of small objects. Another common usage is the situation above, where many objects may be dropped out of memory.
参见 Boost Pool图书馆
关于c++ - 对象池与动态分配,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1250983/