Slashdot Mirror


Mopping Up Mozilla Memory Leaks

mouseman writes "Geodesic Systems, a maker of memory management/debugging software, has a live demo of their Linux product running on the Mozilla nightly builds. It's pretty damn slick -- it detects memory leaks and can show where in the code the leaked memory was allocated and actually recover (GC) the leaked memory. The Mozilla reports actually look pretty good, which jibes with my own impressions of how much it has improved -- see for yourself."

24 of 280 comments (clear)

  1. Alternative memory debugger by nzkoz · · Score: 5, Informative

    As an alternative to this one and purify, I've been using valgrind lately (http://developer.kde.org/~sewardj/). It's defintely worth a look for those of you who don't have access to these commercial tools.

    Of course it doesn't do much in the way of garbage collection (well, anything) but it's still a great tool.

    --
    Cheers Koz
  2. Re:Just what they need... by mellon · · Score: 4, Informative

    It does work on win32!

  3. Maybe not as pretty, but does the same thing... by lordpez · · Score: 5, Informative

    CCMalloc also detects memory leaks and shows you where they took place. Even uses the GPL! It might not be as easy to use (you link your program to it during compile instead of running the it on a completed binary), and doesnt have a web interface, but its functional, and has been out for years.

    I bet someone could write a ld_preload kind of thing that calls ccmalloc, and you could run it on the completed binary as well, so you could run 'ccmalloc ./a.out' just like the 'gsinject -d ./a.out' of this product.

    Here is ccmalloc's page.
    http://www.inf.ethz.ch/personal/biere/proje cts/ccm alloc/

    1. Re:Maybe not as pretty, but does the same thing... by Arethan · · Score: 3, Informative

      yea, it's called memprof. works great. And if you compiled your binary with debugging symbols on, it'll even give you line numbers and stack dumps.

    2. Re:Maybe not as pretty, but does the same thing... by Anonymous Coward · · Score: 1, Informative

      In fact, memprof is based on the same Boehm GC that Geodesic is, though Geodesic's is a closed source fork.

      memprof may lack the web interface, but it has a nice GTK+ GUI. Even handles threads and C++ reasonably well.

  4. Re:Just what they need... by Mr.Intel · · Score: 5, Informative

    Their Analyzer product order page shows a drop down for Linux, Solaris and WIndows 2000. My guess would be they have a port already.

    --
    ASCII tastes bad dude.
    Binary it is then.
  5. Re:Just what they need... by charles+fiterman · · Score: 2, Informative

    We do have one. Try www.geodesic.com

  6. Re:Debugger integration? by charles+fiterman · · Score: 5, Informative

    We have a product that fixes premature frees. This means it will (if asked) ignore all frees and only collect memory when there are no more references to it. It will also eliminate storage leaks. This one isn't a debugging tool in that it doesn't point you at the bug, it just fixes it. We keep hearing people say "I'll go with that if I can take the speed hit." So they connect it and speed improves some times by multiple powers of ten. This is because sand is faster than rust. A single page fault can be slower than many collections combined. So if we eliminate storage leaks and prevent page faults the time we spend doing it is swamped by the time we save.

  7. Garbage collector by PD · · Score: 4, Informative

    If you're writing C++ programs, you should be using a garbage collector, such as Geodesics, or the Boehm collector available freely on the net. I've heard various objections to collection, mostly boiling down to speed issues. At least with the Boehm collector, you can choose to manually manage some memory yourself. In that case, it should be treated as an optimization problem. Write your program with the collector, then profile it. Anywhere you can pinpoint the collector as a major slowdown, handle the memory yourself.

  8. ccmalloc by Kev+Vance · · Score: 2, Informative

    Actually, ccmalloc has a mode like purify to automatically link itself in during the compile process. Not the same thing as preload, but it's just as easy. If you're using, say gcc, change your compiler from "gcc" to "ccmalloc gcc" and ccmalloc will do the rest.

    ccmalloc is a great utility to have if you can't get your hands on purify :)

    --
    F0 07 C7 C8
  9. Re:Interesting by mpsmps · · Score: 2, Informative

    > I must confess that since Purify is not
    > available for Linux, we are always looking for
    > interesting pieces of software to do this job.

    > Now the only question I have are :
    > 1) can it be used as a debugger too ?
    Yes

    > 2) how does it compare to other systems like electricfence ?
    Take a look at the demo (perhaps when it is less slashdotted) and draw your own conclusion. It is pretty self-explanatory.

  10. Have to Check it out after the beatings by Greyfox · · Score: 4, Informative

    Once they've recovered from their thorough slashdotting I'll have to go check 'em out. Efence alone has saved me multiple weeks of debugging time, allowing me to track down memory leaks in our horrid application instantly. This translates into thousands of dollars of development time that can be put to more productive use. I'd estimate that efence has saved my group over 12 thousand dollars in debugging time this year. Now if only I could convince the boss to channel even a small portion of that back into the open source community...

    --

    I'm trying to teach myself to set people on fire with my mind... Is it hot in here?

  11. Memory Usage Trends by joelgrimes · · Score: 5, Informative

    Over the last 6 months, every time I download a nightly or milestone, I've been recording the results of the following test.

    Download the installer and run it. Moz will launch automatically after install. Kill Mozilla and restart it. Bring up the task manager to see how much memory is used.

    Here's the results I've had on my W2k box:

    2001 10/01 build 03 22,540k
    2001 10/15 build 06 21,876k
    2001 10/18 build 03 21,692k
    2001 10/23 build 09 21,984k
    2001 11/16 build 03 21,952k
    2001 11/29 build 03 21,656k
    2001 12/06 build 03 19,868k
    2001 12/10 build 03 19,812k
    2002 01/07 build 03 18,124k
    2002 01/14 build 03 19,064k
    2002 01/17 build 04 19,244k
    2002 02/26 build 03 18,608k
    2002 03/06 build 04 18,220k
    2002 03/11 build 04 17,704k (build 0.9.9)

    That's a decrease of almost 5 megs in memory usage over six months - all the while they've been adding features.
    Significantly, they've added venkman, tabbed browsing, the dom inspector and favicon support.

    Also significant - I don't know why I bother to get the talkback builds anymore - I haven't submitted a crash in 3 months. And I run it all day, every day.

  12. Re:Is there some other Mozilla out there by emok · · Score: 3, Informative

    Make sure you delete all your old profile and setting files before you reinstall again. Installing over a previous version causes problems.

    see: http://www.mozilla.org/releases/mozilla0.9.9/#inst all

  13. Thank Bruce Perens by Anonymous Coward · · Score: 1, Informative
    Efence is the brainchild of none other than the most honorable Bruce Perens,
    fellow Slashdot user and hacker extraordinaire.

    Thank you Bruce, for all you've done for Free Software.

  14. memprof by Arethan · · Score: 5, Informative

    I tried mentioning this in a thread, but it was too quickly drown out. There is a free product that does ld_preload style memory leak detection. It even does memory allocation profiling, so you can find that hidden 'for' loop that is responsible for that extra 15MB of allocated memory. The gui is done with gtk+, so it's easy to use, and will run on most any linux distro these days.

    It's available at http://people.redhat.com/otaylor/memprof/
    Freshmeat has an entry for it as well.

  15. Garbage collectors, leak detection, and Mozilla by Lumpish+Scholar · · Score: 4, Informative
    ... memprof is based on the same Boehm [garbage collector] that Geodesic is, though Geodesic's is a closed source fork.
    Which is pretty funny, because the Boehm-Demers-Weiser garbage collector is already used (cache) with Mozilla (cache) to detect leaks.
    --
    Stupid job ads, weird spam, occasional insight at
  16. Re:What I'd really like... by don_weber · · Score: 2, Informative

    Geodesic supports HP-UX, Linux and Windows under Cygwin.

  17. I have written just such a garbage detector by Anonymous Coward · · Score: 1, Informative

    Years ago in my employment, that is.

    If there is interest, I might recreate it for the Public Domain. It should only take a weekend.

    The principle is simple: go through all writable memory (including the stack and the registers). The idea is -- and I didn't invent this -- what looks like a pointer [to the heap] is a pointer. Those heap blocks that were not pointed to, are reported as garbage.

    A special allocator package records the calling frame so you can tell where the block was allocated. Other niceties are included. The tools is implemented as function calls that you typically invoke from the debugger.

    While the principle is heuristic, the practical experience (with Solaris and Interactive UNIX) is that it instantaneously finds all garbage.

    Marko

  18. Memory Leak Detectors and Garbage Collectors by Taco+Cowboy · · Score: 5, Informative



    I'm gonna need people's help to add to the list below.

    Here is a list of (freeware) Memory Leak Detectors and Garbage Collectors -

    ccmalloc
    http://www.inf.ethz.ch/personal/biere/projects/ccm alloc/

    Valgrind
    http://developer.kde.org/~sewardj/

    Boehm Collector
    http://www.hpl.hp.com/personal/Hans_Boehm/gc/

    Parallel Collector on Message Passing Environment
    http://www.yl.is.s.u-tokyo.ac.jp/gc/dgc/

    If there are more out there, would you kindly add what you have to the list, please ?

    Thank you !

    --
    Muchas Gracias, Señor Edward Snowden !
    1. Re:Memory Leak Detectors and Garbage Collectors by cortense · · Score: 3, Informative

      LeakTracer
      http://www.andreasen.org/LeakTracer/

      MemWatch
      http://www.linkdata.se/sourcecode.html

      These are two free memory debuggers that I've used, and had much success with.

  19. Nice leak detectors built into Mac OS X by Mneme · · Score: 5, Informative

    The Mac OS X's malloc library has built-in support for providing good leak detection. The command line tool leaks (installed with the free developer tools). Although leaks can be run on any program, it works best when you set the enviromment variable MallocStackLogging, which causes the system to provide complete stack frame information about when each piece of leaking memory was allocated.

    Also of interest are the malloc_history and heap command-line tools. They tell you lots of interesting information about exactly what is on the heap and how it got there. The malloc library also detects double frees by default (making it immune to the recent zlib security vulnerability) and can also detect writing on free blocks, etc. Very nice.

    Finally there is a graphical application, MallocDebug which provides similar information on memory leaks and memory use but also provides an easy to use memory-browser interface. Unlike simple leak detectors, you can explore your program's memory space and discover memory that isn't strictly "forgotten" by your program (it still has valid references to it) but should perhaps have been deleted anyway (e.g., finding memory allocated for a splash screen graphic). This last application requires that the code use a special library, but it is easy enough to make dynamically-linked programs use this library (thanks to Darwin's equivalent of LD_PRELOAD, DYLD_INSERT_LIBRARIES).

    Although you can debug any code with these tools (from command-line tool to X-windows, Carbon or Cocoa app), they really shine debugging Objective-C, because Objective-C provides enough runtime information for the tools to tell you lots about the objects that are sitting there on the heap.

  20. you don't need Geodesic's stuff by markj02 · · Score: 4, Informative
    If you want leak detection and garbage collection, use the Boehm/Weiser/Dehmers garbage collector. It works with C, C++, and a lot of other languages. Mozilla should probably be using it by default. For plain leak detection, there are plenty of highly functional open source packages. "dmalloc" comes to mind (although it's not completely unencumbered). For array bounds violations, you can use valgrind, ElectricFence, and other free tools.

    A more basic question to ask, however, is why something like Mozilla has memory leaks in the first place. Avoiding memory leaks in C is hard because there simply are no hooks in C to automate resource management. But C++ has constructs that make writing leak-free code and code that doesn't use bad pointers pretty easy. Since switching from C to C++ a few years ago, memory leaks and bad pointers have simply not been an issue anymore in my code.

  21. spellchecker by ksheff · · Score: 2, Informative

    Have you tried out the one at http://spellchecker.mozdev.org?

    --
    the good ground has been paved over by suicidal maniacs