选择哪个对象池后备存储?

发布于 2024-09-27 06:58:50 字数 307 浏览 1 评论 0原文

在我们的 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

微凉徒眸意 2024-10-04 06:58:50

到目前为止这个问题还没有答案,所以我会写我自己的答案:

最终使用了 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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文