Debugging memory leaks

Steven D'Aprano steve+comp.lang.python at pearwood.info
Thu Jun 13 22:40:53 EDT 2013


On Thu, 13 Jun 2013 20:15:42 +0000, Giorgos Tzampanakis wrote:

>> Therefore: if the leak seems to be small, it may be much more advicable
>> to restart your process periodically (during times where a restart does
>> not hurt much) rather than try to find (and fix) the leaks. Only when
>> the leak is large enough that it would force you to too frequent
>> restarts, a deeper analysis may be advicable (large leaks are easier to
>> locate as well).
> 
> 
> Am I the only one who thinks this is terrible advice?


Sub-optimal, maybe, but terrible? Not even close. Terrible advice would 
be "open up all the ports on your firewall, that will fix it!"

If it takes, say, 200 person-hours to track down this memory leak, and 
another 200 person-hours to fix it, that's an awful large expense. In 
that case, it would surely be better to live with the inconvenience and 
mess of having a nightly/weekly/monthly reboot. On the other hand, maybe 
it will only take 1 hour to find, and fix, the leak. Who knows?

My advice is to give yourself a deadline:

"If I have not found the leak in one week, or found and fixed it in three 
weeks, then I'll probably never fix it and I should just give up and 
apply palliative reboots to work around the problem."

Either that or hire an expert at debugging memory leaks.



-- 
Steven



More information about the Python-list mailing list