One of the most useful tools available to a
C programmer, Purify finds
memory bugs for you -
buffer overflows,
leaks, and others of their their ilk. Purify keeps track of every call to memory allocation functions such as
malloc, and then on every memory reference, makes sure:
- You're accessing memory that's been properly allocated.
- Your access is within the bounds of the memory allocation. (Buffer overflow)
- You're not trying to read from memory that's never been written to. (Uninitialized memory read.)
- You're not trying to use memory after you freed it.
Once the program is done, it then reports on memory
you forgot to
free (and what function allocated it).
To use purify, you simply add the purify command to the front of the linking command you use to build your application. Purify inserts code into your application and into copies of all the libraries your application links with. Unfortunately, this makes the program run very slowly and only works for programs you can link (which usually means having source, or at least all the object files). Some debuggers, such as Sun's dbx, contain similar technology that doesn't require relinking or having source, but they are not as common as Purify.
Purify was originally made by Pure Software, who merged in 1996 with Atria to form Pure Atria, which was then bought in 1997 by Rational Software. Rational was in turn bought by IBM in late 2002. As of late 2003, IBM sells it under the name IBM Rational PurifyPlus for Solaris, Linux, Irix, HP-UX, and Windows NT/2000/XP.