Oct 17, 2023

Making C++ Software Allocator Aware

by Pablo Halpern.

View the full article Making C++ Software Allocator Aware

Abstract

This paper teaches the reader how to write Allocator-aware (AA) software, a term for software that allows a client to supply an allocator at object construction. AA software provides the application developer with an effective, lower-cost alternative to writing bespoke types having individually customized memory management. Creating AA software, however, can be considerably more complex than using existing AA software. After introducing the requirements for an AA type compatible with BDE guidelines, this paper presents the steps of transforming a simple struct into an AA class and then explains how to accomplish this task for increasingly complex categories of types, culminating with container class templates.

BDE 4.0 introduced a number of facilities, described herein, that make it easier to author AA software. Though his paper is written primarily for Bloomberg engineers — both those who are new to AA concepts, and those who have experience using older patterns of writing AA software — developers outside of Bloomberg can also benefit from what we learned.