DOC HOME SITE MAP MAN PAGES GNU INFO SEARCH PRINT BOOK
 
No More Memory Leaks - fs(3C++)

No More Memory Leaks - fs(3C++)

Memory allocation bugs are among the most pernicious, difficult-to-locate bugs in C programs. Although C++ allows the programmer to manage the freestore at a higher conceptual level than was possible in C (as a collection of objects rather than as chunks of memory), C++ still admits all the allocation bugs that were possible with malloc.

This tutorial presents fs, a symbolic freestore manager for C++. fs allows the programmer to view the contents of the freestore symbolically during debugging. fs maintains, for each object in the freestore, the type, birthplace, size, and address of the object. fs also allows the user to set ``watchpoints'' on objects: when a ``watched'' object is about to be deleted, program execution first breaks and the programmer is notified. The entire freestore can also be watched for arbitrary deletion and creation events. With fs, finding and fixing memory leaks is an almost effortless task.

fs can be used on programs that define their own new and delete operators. It needs no special debugger, and can even be used when debugging with printf's.


Next topic: The Problem

© 2004 The SCO Group, Inc. All rights reserved.
UnixWare 7 Release 7.1.4 - 27 April 2004