Hacker Newsnew | past | comments | ask | show | jobs | submitlogin
Why you should worry about memory leaks (gnome.org)
19 points by soundsop on Aug 26, 2008 | hide | past | favorite | 8 comments


Let's keep things in perspective. I'll take ten memory leaks over one segmentation fault any day. Also, not every forgotten pointer constitutes a memory leak. To talk about a memory leak, your program has to eat up the amount of memory proportional to its running time, or input size. If you just allocate some constant memory for your data structures at startup it is not a memory leak. Still of course it's nice to free it up at exit (for example for reasons mentioned in the article) but sometimes it's not convenient or practical. So let's not get too uptight about it.


[Mozilla] leaks like crazy

Disturbing.

unref, free, g_free

One of my professors joked that all non-trivial C and C++ projects begin with hiring a guy who already wrote a garbage collector.


This is one of Mozilla's problems right now: it leaks like crazy so how are you ever going to know if you just added to the problem?

Precisely. You should worry about memory leaks so you don't have web browsers using up 800MiB while doing absolutely nothing and not using any plugins: http://neosmart.net/gallery/v/apps/Firefox/Firefox+Hole.png....

Then again, when you're leaking several hundred MiB per tab in Version 2, you can fix up a memory leak or two, halve the problem, then go around claiming "extraordinary improvements to memory management" come version 3. Oh, wait.....


Maybe I'm just jaded, but this seems like a really basic primer on memory management. Is mozilla failing to meet these standards? Somehow my guess is that the challenges facing the project are a bit more sophisticated. I have absolutely no evidence to support that supposition however.


This is a page from the Gnome developer guidelines. It's not about Firefox per se. And it looks pretty old to me; they're talking about "Mozilla" as a product, which it hasn't been for several years now. My guess is that this was written during the early push for Gnome 2.0, maybe four years ago.

It's sane (if unsurprising) advice. Using it as evidence for the current state of Firefox's memory management strikes me as a poor idea.


Stronger evidence for the current state of Firefox's memory management comes from the Windows Task Manager ;-)

(284M and counting! Yesterday my Linux Firefox was at upwards of 350M, though it's now at 144M after restarting it.)


It is very basic - but then again, just about any concept in coding is when you look at it from the perspective of the principals involved. But take something basic (a malloc command) - pass the object around back and forth, left and right, across multiple classes and libraries, casting it this way and that, and you'll realize that you've got objects that aren't being freed right - and when you attempt to free them, you're application will crash since other bits of code need access to what you just trashed from the memory.

I'm not defending the FF team - I think they've done a terrible job managing memory in their browser... but it's an understandable mistake and doesn't come from ignoring the rules so much as it is not picturing the entire codebase in your head when passing objects around.


valgrind is excellent for tracking down leaks and these days used quite extensively in the open source world.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: