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
- 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).
- 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
- Conclusion: effective and simple.
Purify
- 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.
- 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
- Simple to use, very nice interface but need a relink.
Garbage collector (bundled with Sun Workshop 5.0)
-
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
- 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.
- 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...)
- Seems to be quite complicated to use in comparison with dbx or
Purify. No obvious advantages to me for debugging.
Watchmalloc
- drop-in replacement for malloc and gang
- documentation: man watchmalloc
- 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