选择哪个对象池后备存储?
在我们的 C# (.NET 4.0) 应用程序中,我们以不同大小的块分配和取消分配大量内存。我们希望迁移到对象池,以提高性能。
我们已经实现了对象池并看到了一些性能改进。我们目前正在使用基于堆栈的后备存储。其他可能的替代方案是基于队列的存储、ConcurrentBag<>等等。基于商店,列表>> 我想后备存储
的选择实际上取决于应用程序的特性,因此我们现在正在使用所有这些不同的后备存储实现对象池并测试性能。
但是,我真的很想听听您对对象池的不同后备存储的优缺点的看法。
谢谢
In our C# (.NET 4.0) application, we allocate and de-allocate a lot of memory, in different size chunks. We want to move to an object pool, to improve performance.
We implemented an object pool already and saw some performance improvement. We're currently using a stack-based backing store. Other possible alternatives are, queue based store, ConcurrentBag<> based store, List<> based store, etc.
I guess the choice of backing store really depends on the application's characteristics, so we're now in the process of implementing the object pool with all these different backing stores and testing the performance.
However, I'd really like to hear your thoughts on pros and cons of different backing stores for object pooling.
Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
到目前为止这个问题还没有答案,所以我会写我自己的答案:
最终使用了 Stack<>。归功于:http://geekswithblogs.net/robp/archive/2008/08/07/speedy-c-part-2-optimizing-memory-allocations---pooling-and.aspx
我们刚刚进行了实验具有不同的后备存储和 Stack<>在我们的特定情况下,结果是最快的。
No answers to this question so far, so I'll write my own answer:
Ended up using a Stack<>. Credit to : http://geekswithblogs.net/robp/archive/2008/08/07/speedy-c-part-2-optimizing-memory-allocations---pooling-and.aspx
We just experimented with different backing stores and Stack<> turned out to be the fastest in our particular case.