Question

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

Was it helpful?

Solution

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.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top