Uninitialized values and memory leaks

Dirk Hohndel dirk at hohndel.org
Wed Oct 2 08:31:02 UTC 2013


On Wed, 2013-10-02 at 15:41 +0200, Patrick Valsecchi wrote:
> Hi,
> 
> I ran subsurface with valgrind and it found a few errors. The leaks
> are mainly a one time thing, but I needed to fix them to reduce the
> noise and find the real bad leaks.
> 
> I've left one leak with a FIXME comment. This one is a bit tough. It 
> would be way easier if the dive structures were using QString instead of 
> char*. What is the plan with the GTK UI? If it is going to be dropped, I 
> suggest to switch to QString, QList and QMap instead all all those C types.

Much of the original code that is very well tested and self consistent
(and well understood by the older contributors) we decided to leave
unchanged. There are some people here (cough, cough) who aren't well
described as "C++ fans" and prefer simple data structures...

Long story short - I don't see this happening.

And frankly, most memory leaks are entirely harmless. Basically anything
that leaks a fixed amount of memory PER EXECUTION is mostly cosmetic.
Yes, it creates noise in memory debuggers - but often fixing these
static leaks creates code that is far more fragile and harder to
maintain. We actually introduced bugs trying to fix memory leaks.
Obviously things are different with leaks that increase with use / over
time, etc. Those are bugs that need to be fixed.

> Please have a look at the patch in attachment (bigger than my previous 
> ones).

I will - I'm again in an all day meeting today with very limited time
until late tonight. Not sure when I'll get to it.

> I think my next "mission" is to figure out why there is only the graph 
> in the printouts when the screenshot [1] shows some text and a table 
> with some data below them. Unless it's a known problem and somebody 
> already works on that?

Lubomir is tackling the printing nightmare :-)

/D



More information about the subsurface mailing list