Re: Memory leaks

On Wed, 9 Feb 2011, John Emmas wrote:

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.

You initialized the GTK library stack. That involves lots of
allocations that have nothing specifically to do with your
program. The pointers are maintained at the level of the
library code, not your app.

I'm afraid you're talking through your hat here. Have your ever
worked through the code for even a simple shared library that
saves state?  Freeing all memory on exit can be useful as a
debugging exercise (e.g. if you get a segfault that tells you
something), but aside from that it's a pure waste of CPU cycles.

Allin Cottrell

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