C Memory Management – Importance of Fixing Memory Leaks

cmemory

I found by Valgring that some GTK+ programs leaks memory. How important it is to fix those leaks? I mean, often those programs works very well but on the other hand, one can never be sure if one wants to copy part of the leaking code to some other program. And I'm not sure if the idea of GTK+-programs is to work fast and therefore there are leaks.

So if I sometimes find a memory leak in an open source program, should I fix it or are there for example efficiency issues and therefore programmers original idea was to write some small leaking code?

Best Answer

How important it is to fix memory leaks depends on the severity of the problem and what else you have to do that is important. My experience is that small memory leaks tend to be rather benign for most applications. The lifetime of a desktop app session is not usually long enough to see any degradation from a small memory leak.

If you are writing a server that runs 24/7, then small memory leaks can add up over time and become a major problem. But that's why many companies schedule their servers to restart daily or weekly. The effort to find memory leaks is often excessive relative to what might be gained, so it's easier to restart the servers on a regular basis and move on to more important things.

Related Topic