Memory debugging capabilities on Sun

Here is a summary of memory debuggers on Sun/Solaris.
Feedback is welcome.


Table of Contents


Run Time Checking (RTC) in dbx

  1. dbx has got some RTC capabilities built-in (in dbx: help rtc).
    Roughly: dbx a.out, check -all, run
    One can use within dbx various commands such as "showleaks" and "showleaks -v".
    It's a dbx thing, so you don't need to recompile anything but maybe with -g to get some symbolic information. Therefore it works with any Sun compilers (C, C++, Fortran).
  2. You can run in batch dbx to get some checks with no recompilation.
    For that use bcheck (man bcheck for more info).
    It's as simple as:
    >bcheck a.out
  3. Conclusion: effective and simple.

Purify

  1. Reed Hastings and Bob Joyce. Purify: Fast detection of memory leaks and access errors. In Proceedings of the Winter USENIX Conference, pages 125--136, January 1992.
  2. Works with:
    • Sun cc and gcc
    • Sun CC
      (Note: to work with purify 4.2, the Sun C++ compiler 5.0 needs the option -compat=4 (or -compat) (backward compatibility with the compiler 4.2)).
    • Sun f77 and NAG f95
  3. Simple to use, very nice interface but need a relink.

Garbage collector (bundled with Sun Workshop 5.0)

  1. There's a garbage collector bundled with the Sun compilers 5.0 (Great circle).
    Consequences:

    • help development (leaks detection and memory usage analysis)
    • fix lousy programs.
      (theoretically, we could rebuild a product with that library to fix any memory leaks on Sun. These leaks will still exist on other platform though.)

    See: file:<install-directory>/SUNWspro/SC5.0/htmldocs/locale/C/gc/start.html

  2. A web interface to the garbage collector is provided, which allows to spy a program (for instance an Iris Explorer module). That reports the leaks and memory usage.
  3. To instrument a program, either:
    • link with some libraries (c.f. web help)
    • use memdb (c.f. web help) (similar to bchek but web enabled)
      (I haven't managed to make this command work for some reasons...)
  4. Seems to be quite complicated to use in comparison with dbx or Purify. No obvious advantages to me for debugging.

Watchmalloc

  1. drop-in replacement for malloc and gang
  2. documentation: man watchmalloc
  3. no recompilation for dynamically linked applications (env LD_PRELOAD=watchmalloc.so.1 <app-name>)

$Id: SunMemoryDB.html,v 1.22 2007/05/23 10:10:35 adesitter Exp $

by Arnaud Desitter.
© Arnaud Desitter, 1999, 2000, 2003