Re: Memory leaks



Years ago my text retrieval package had an option to call free() for all
the data structures on exit, basically just for debugging. ÂIt made the
programs often go really slow when they exited - adding tens of seconds
wasn't uncommon.

Maybe there are corner cases (although the platforms GTK can run on
are pretty modern nowadays). But as someone we all know once said
"premature optimization is the root of all evil". Those cases are
definitely exceptions. Optimizing cleanup routines is definitely
something I don't hear about much.

So, I agree it's a good idea to do (and as I mentioned, I've done it
myself in the past) but it's for sure not a case of adding one simple
line of O(1) code...

I'm not sure about malloc()/free() implementations but I'm pretty sure
they can use a (partial) lookup table bringing the complexity quite
close to O(1). I would be appalled if I found modern implementations
to be subpar. But, as I've said above, one should only consider
looking at this from the efficiency point of view when you pin-point
that part of the program as wasting too many cycles, especially
compared to other parts of the program (how much does gtk_init() take,
is that any kind of problem and could gtk_cleanup() take longer?).



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