The Firefox Memory Leak of Doom

A few minutes ago, I realized my disk was paging when I ran Vim. A quick glance at gkrellm confirmed it: swap space was nearly exhausted and physical memory was maxed out. The usual suspect was responsible — firefox-bin was holding roughly a gigabyte of X pixmap memory.

I started digging and found that I had a window open to the Nagios status map for several hours. That page includes a 992 x 1021 pixel PNG and refreshes itself about once a minute. After closing Firefox, I brought up xrestop, reopened the status map, and watched. X pixmap usage for Firefox jumped by about 2500K per refresh. Within ten minutes, that number had ballooned to roughly 50MB.

What stands out is that this is the same image loaded repeatedly. This isn't just the back-page cache at work — Firefox appears to retain every image it fetches in X memory, and it never releases them. Closing the tab, closing the window, clearing the cache — nothing short of terminating the process seems to free those pixmaps.