next up previous contents index
Next: 2.4.1 Reference counting smart Up: 2. Software Architecture Previous: 2.3.2 Object creation   Contents   Index

2.4 Memory Management

Memory management in a C++ program is a complex process, and is often done incorrectly or inconsistently. We have settled on a reference counting design described as follows.

All objects using reference counting maintain an internal reference count to determine when an object can safely delete itself. Each time that a pointer is obtained to an interface, the object's reference count is incremented by calling Ref(). It is the obligation of the user of the pointer to explicitly Unref() the pointer when done. When the reference count falls to zero, the object is deleted.

The burden for calling Unref() is somewhat relieved by the use of the reference counting smart pointer class described below.

Users using a low-level API who wish to explicitly allocate non-reference-counted objects on the heap, using operator new, are responsible for deleting such objects.

Packet objects are handled differently (without reference counting); their design is described in the next chapter.



Subsections
next up previous contents index
Next: 2.4.1 Reference counting smart Up: 2. Software Architecture Previous: 2.3.2 Object creation   Contents   Index
Tom Henderson 2007-08-15