From 73049f4edd7645252ec032b2f738debff3e92505 Mon Sep 17 00:00:00 2001 From: "mcafee%netscape.com" Date: Sun, 26 Sep 1999 20:27:56 +0000 Subject: [PATCH] Making this document look like a Mozilla doc, minor clean-up. git-svn-id: svn://10.0.0.236/trunk@49105 18797224-902f-48f8-a5cc-f745e15eee43 --- mozilla/tools/leaky/leaky.html | 101 ++++++++++++++++++++++----------- 1 file changed, 69 insertions(+), 32 deletions(-) diff --git a/mozilla/tools/leaky/leaky.html b/mozilla/tools/leaky/leaky.html index 1ef3b132e15..ec91b2a715c 100644 --- a/mozilla/tools/leaky/leaky.html +++ b/mozilla/tools/leaky/leaky.html @@ -1,43 +1,55 @@ - - +Leaky - + -

-About Leaky

+
+Leaky +

Leaky is a program which will help you find memory leaks, and as of late, -help you debug reference count problems with xpcom objects. -

To use leaky you must first build it. I've made it work only on x86 -linux. To work on other platforms you will need to: -

    -
  1. -Implement CrawlStack in libmalloc.cpp
  2. +help you debug reference count problems with xpcom objects.
    +
    -
  3. -Implement DumpAddressMap in libmalloc.cpp and in ShowLibs.cpp
  4. + +Get the Source +
    +Leaky is not currently part of the default SeaMonkey module,
    +you will need to explicitly pull the source:
    +
    +
    +  cvs checkout mozilla/tools/leaky
    +
    +If there is enough demand, we can make this part of +the default SeaMonkey module. +
    +
    -
  5. -Either support LD_PRELOAD in your dynamic linker *or* produce a library -that wraps your libc malloc (see config.h for some clues)
  6. + +Building it +
    +
    +  ./configure --enable-leaky
    +
    +Top-of-tree build should Just Build It and leaky will show up in dist/bin. +
    +
    -
  7. -Implement symbol table reading code (see coff.cpp, elf.cpp and bfd.cpp -for examples; at the time of writing this document only bfd.cpp was known -to work)
  8. -
-After its built, you can use TestPreload and TestMalloc and ShowLibs to + +Using Leaky +
+ +After it has been built, you can use TestPreload and TestMalloc and ShowLibs to debug your implementation. -

By setting the LIBMALLOC_LOG environment variable you control how much +

By setting the LIBMALLOC_LOG environment variable you control how much information is logged during the programs execution. See libmalloc.h for -a definition of the values to use. If you are using LD_PRELOAD, here is +a definition of the values to use. If you are using LD_PRELOAD, here is one way to run your program:

env LD_PRELOAD=/full/path/to/libleaky.so LIBMALLOC_LOG=1 my-program
-The debugging malloc library creates two files - "malloc-log" and "malloc-map". +The debugging malloc library creates two files, malloc-log and malloc-map. The malloc-log file can be quite large for large programs (e.g. mozilla) so be prepared to have alot of disk space. The malloc-map is tiny.

Once your program has completed execution you can use leaky to look @@ -86,14 +98,11 @@ file of around 5 to 10 megabytes and the resulting converted log file will be 10 to 20 times that so be prepared to have alot of disk space. It helps a great deal to narrow down your problem space to reduce the log file size... +
-


- -

A quick additional note. Leaky now has a "graph" output option. -If you do this:

- -
leaky -gqx viewer malloc-log | c++filt | sed -e 's/&/&/g' > /tmp/GQ0.html
- +Leaky now has a "graph" output option. If you do this:

+
+  leaky -gqx <program-name-goes-here>  malloc-log | c++filt | sed -e 's/&/&/g' > /tmp/GQ0.html

Then leaky will make a graph of the leaks [-g] and output that graph in xml format (currently actually html...) [-x]. I use c++filt to translate the C++ mangled names into ascii and then use sed to make it @@ -103,5 +112,33 @@ legitimate html and off it goes to a file.

present you with a treeview of the leaks that you can click on to open/close sections. Enjoy!

+
+
+ + +Porting to non-Intel/Linux +
+ +

Initial version works only on x86 linux. To work on other platforms you will need to: +

    +
  1. Implement CrawlStack() in libmalloc.cpp
  2. +
  3. Implement DumpAddressMap() in libmalloc.cpp and in ShowLibs.cpp
  4. +
  5. Either support LD_PRELOAD in your dynamic linker, or
    produce a library +that wraps your libc malloc (see config.h for some clues)
  6. +
  7. Implement symbol table reading code (see coff.cpp, elf.cpp and bfd.cpp +for examples; at the time of writing this document only bfd.cpp was known +to work)
  8. +
+ +
+ +Last modified: Sun Sep 26 13:15:33 PDT 1999 + +
+Send comments to Kipp Hickman
+
+ + +