2

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

4

1 回答 1

1

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

最终使用了 Stack<>。归功于: http: //geekswithblogs.net/robp/archive/2008/08/07/speedy-c-part-2-optimizing-memory-allocations---pooling-and.aspx

我们只是尝试了不同的后备存储,而 Stack<> 在我们的特定情况下是最快的。

于 2011-02-04T08:13:11.167 回答