Automating object pooling using IDisposable and finalizers

Last week we looked into the concept of object pooling, and how it can be used to increase performance by reusing objects that are expensive to create.

We also implemented a generic static class to make using object pools as simple as possible. Today I want to expand on the topic by showing how we can go even further and completely automate the pooling.

Continue reading →

Reusing objects with generic object pooling

Over the last couple of months I’ve been working a lot with WPF (Windows Presentation Foundation), the popular user interface framework by Microsoft.

Something that I noticed quite quickly is how expensive it can be to create WPF controls in code. It could take up to several milliseconds to create a new interface element – even simple ones. The interface I was working on had to be very flexible and could change often however, which would cause it to freeze for noticeable durations regularly, which is unacceptable.

The way I solved that problem is by using object pools.

Continue reading →