Only visible images are now kept in memory, resulting in major memory usage reduction

Oct 1, 2013 12:58 GMT  ·  By

Firefox is getting some major memory usage improvements thanks to changes in the way the browser handles image-heavy pages. Up until Firefox 23, all images on a page were downloaded, processed, i.e. decoded, and then kept in memory for as long as the page stayed in the foreground.

This meant a lot of memory was used unnecessarily, but the problem wasn't truly noticeable except on pages with a lot of images, hundreds or more.

But, as of Firefox 24, images that aren't visible at any given time are discarded from memory, even if all of them are decoded first. In Firefox 26, this was changed even further so that only the visible images are decoded and stored in memory. What's more, the changes don't affect scrolling speed, Mozilla says.

"Timothy Nikkel fixed bug 847223, which greatly reduces peak memory consumption when loading image-heavy pages. The combination of this fix and the fix from bug 689623 — which Timothy finished earlier this year and which shipped in Firefox 24 — have completely solved our longstanding memory consumption problems with image-heavy pages," Mozilla explained.

The improvements are clearly visible in a less than scientific test Mozilla put together. It shows how different versions of Firefox handle an image-heavy page. In Firefox 23 memory usage shoots up to about 3GB and stays there as long as the page is open.

In Firefox 24, there's still an initial spike, but memory usage drops after that. With Firefox 26, memory usage stays low at a few hundred MB for the duration of the test.

Granted, the bug was only annoying on pages with a way too many images. But it was an issue that only plagued Firefox, as other browsers handle these pages much better. What's more, even if the improvement is smaller for sites with fewer images, it's still an improvement and it adds up.