O'Reilly logo

Efficient C++ Performance Programming Techniques by David Mayhew, Dov Bulka

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Version 2: Fixed-Size Object Memory Pool

Version 1 is limited to managing Rational objects only. What if we wanted a memory manager for some other class of a different size? Duplicating the memory management logic for every class will be an unnecessary waste of developer time. If we look at the implementation of the Rational memory manager, it becomes apparent that the memory management logic is really independent of the particular Rational class. The only dependency is the size of the class object—a good candidate for a template implementation of a memory pool. The memory pool will manage a pool of available objects of a certain type. A template implementation would allow us to vary the specific class that we are managing.

 template < class ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required