-
Book Overview & Buying
-
Table Of Contents
C++ Memory Management
By :
In Chapter 7, we examined various ways to overload the memory allocation operators, which are new, new[], delete, and delete[], in order to grasp the syntax involved in writing these operators as well as how they can be used in client code. We discussed how these operators interact with exceptions (even in the case of the nothrow versions) and saw why they should, in most cases, be written in groups of four or multiples thereof. For example, code that calls the nothrow version of operator new() to obtain some pointer, pV and later on calls delete p will quickly get in trouble if one overloads the nothrow version but not the “regular” one, as both might then end up not being compatible with one another.
What we have not really discussed is how our code could benefit from taking control of these operators. There are indeed multiple uses for this: tracing how or where memory is allocated, measuring memory fragmentation in a process,...