Raymond Chen quote of the day · 2012-01-05 19:59 by Wladimir Palant
I regularly use a program that doesn’t follow this rule. The program allocates a lot of memory during the course of its life, and when I exit the program, it just sits there for several minutes, sometimes spinning at 100% CPU, sometimes churning the hard drive (sometimes both). When I break in with the debugger to see what’s going on, I discover that the program isn’t doing anything productive. It’s just methodically freeing every last byte of memory it had allocated during its lifetime.
Somehow I have the impression that I know which program he talks about. While I understand why Firefox/Gecko is doing this and that fixing this issue would require pretty complicated and dangerous architectural changes, I wonder whether there is some relatively simple partial solution. For example, what about modifying the
free() function of the custom memory allocator used by Firefox to just stop doing anything when the process is exiting? It shouldn’t have any noticeable effect on anything: objects will still be “released” when their ref count reaches zero and their destructors will still run but the memory management overhead at shutdown will go away. But of course I don’t know how much of the shutdown delay is caused by the memory management and how much of it is simply destructors hugging object data one last time.
Commenting is closed for this article.