Re: Memory leaks




On 9 Feb 2011, at 20:06, Allin Cottrell wrote:

You're missing Tor's point. Yes, all memory leaks are bad, but
most (all?) of the instances of not-explicitly-released memory
in the GTK stack are _not_ leaks. If you still have a pointer to
it, it ain't a leak, even if a dumb debugger says so.

But my original example looked like this:-


     Gtk::Main *app = new Gtk::Main (&argc, &argv);

     delete app;


How could there possibly be valid pointers still lurking after those operations?  Sure, there'll be pointers 
and they'll be pointing to some memory - but neither of them is valid any more.  I think what Tor meant (and 
this does admittedly have some validity) was that the un-released memory will eventually (in fact, soon) be 
released by the operating system anyway, so what purpose does it serve to release it specifically?  My 
argument against that was that it makes it a lot easier for a leak detecting utility to do its job properly.

But quite apart from that, there's bound to be a suspicion about whether the true reason for not fixing such 
leaks is really one of scale.  Remember that just that one gtkmm call left me with literally hundreds of 
leaks.  Supposing there'd only been six leaks.  Would that have imbued more motivation to plug them?  I 
suspect the answer is "yes".

John


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]