Chrome and Firefox 3.5 Memory Usage

You are interested in how the Google Chrome 3.0 Dev, Firefox 3.5 RC, Safari 4.0 for Windows, and Opera 10b web browsers manage memory on the Windows Vista operating system over moderate usage, such as with 150 top web sites. These numbers can be measured but there are complexities involved in measuring memory. Here we look at a program that simulates a user visiting the top 150 web sites from Alexa from the command line, with visits occurring at short but varying intervals in many tabs.

Chrome and Firefox memory usage

Browser memory in 2009

Here we note that the previous study of browser memory usage on dotnetperls.com was performed by monitoring a user's actual interactions with the browsers in a memory tabulation program. Due to the burden of having to use certain browsers for three hours in a row, this experiment automates all URL visits through the command line. This means that each browser was tested for exactly 150 remote URLs, using the same command-line arguments for different executables.

Benchmark description

Here we mention the general overview of the benchmark used in this article. Each browser was configured to open new URLs from the command line into new tabs, with each previous page being kept accessible from the tabbed interface. After 30 URLs were tested in all four browsers, the software prompted the author to close all tabs in the browsers except one tab. This simulates a user opening many sites in one sitting and then taking a short break and closing pages; it neglects the back/forward mechanism.

Memory checkpoints. The memory watcher utility used in the benchmarks is configured to obtain an array of all processes running on the Windows system every 3 seconds. It then stores all those figures in megabytes in internal data structures. When a process with the same name such as "chrome.exe" is encountered more than once, its total size is accumulated, yielding a total of all the "chrome.exe" figures together. The X axis indicates the time checkpoints and 1 checkpoint is equal to 3 seconds.

System configuration

This exploration of browser memory usage was undertaken on a Windows Vista Home Premium system with 4.00 GB of memory installed and the 32-bit version of Windows. Visual Studio and the .NET Framework 3.5 SP1, the author's memory watching utility, and the command-line driver for the browser were used.

Alexa sites

Because every user has a different selection of sites he uses, the sites tested programmatically in this examination were taken directly from the Alexa top sites CSV file at http://s3.amazonaws.com/alexa-static/top-1m.csv.zip. This list is the property of the Alexa service and will not be made available on dotnetperls.com. The CSV used was downloaded on June 19, 2009.

Results

Here we see the results of the experiment when performed as described above. During the experiment, 384 memory checkpoints were taken, which amounts to 1152 seconds or 19.2 minutes. Google Chrome posted the highest maximum memory usage when all chrome.exe processes were summed, reaching 1.18 gigabytes, while Firefox posted the lowest maximum memory levels of 327.65 megabytes. This means Firefox used 73% less memory during peak periods.

--- Maximum memory used ---
    Peak memory usage measured during experiment.

Chrome:  1216.16 MB      [Largest]
Firefox:  327.65 MB      [Smallest]
Opera:    554.11 MB
Safari:   517.00 MB

--- Average memory used ---
    Average of all memory checkpoints throughout experiment.

Chrome:  543.83 MB       [Largest]
Firefox: 166.82 MB       [Smallest]
Opera:   347.45 MB
Safari:  319.44 MB

--- Final memory used ---
    Figures taken after all tabs were closed at end.

Chrome:  109.49 MB
Firefox: 106.66 MB       [Smallest]
Opera:   441.49 MB       [Largest]
Safari:  349.62 MB

More results. Firefox 3.5 also had the best average memory usage figures, meaning that it may consume the least memory of these browsers when used for the Alexa sites as tested in the benchmark. Finally, Chrome and Firefox posted the best memory figures at the end of the browsing session, with Opera consuming 4.1 times more memory than Firefox at the end of the test.

Memory champion

Here we note the browser that has the best results in the experiment at every level. Firefox 3.5 used the smallest amount of memory during its peak, it used the smallest amount of memory when all points were averaged, and it used the smallest amount of memory at the end of the experiment after all tabs were closed. Firefox 3.5 continues Firefox 3.0's legacy of being the most memory efficient browser in this style of experiment.

Source code

Here we see the source code written in the C# programming language targeting the .NET Framework that issues commands to the browsers specified in the static string array. All the five browsers support command-line arguments of the form of a URL with no prefix. The program uses pauses with the Thread.Sleep method to try to introduce more unpredictability into the benchmark. This could avoid edge cases where the a certain timing could interact with a browser's cache algorithms in a less representative way.

~~~ Console program that uses Process.Start (C#) ~~~

using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Threading;

class Program
{
    /// <summary>
    /// Number of points to close stuff.
    /// </summary>
    const int _interrupt = 30;

    /// <summary>
    /// Browsers urls are sent to.
    /// </summary>
    static string[] _browsers =
    {
        @"C:\Program Files\Mozilla Firefox 3.5 Beta 4\firefox.exe",
        @"C:\Program Files\Safari\Safari.exe",
        //@"C:\Program Files\Internet Explorer\iexplore.exe",
        @"C:\Program Files\Opera 10 Preview\opera.exe",
        @"C:\Users\Sam\AppData\Local\Google\Chrome\Application\chrome.exe"
    };

    static void Main()
    {
        var r = new Random();
        var ct = 1;
        foreach (var url in GetUrls())
        {
            if ((ct % 30) == 0) // Notify
            {
                Console.BackgroundColor = ConsoleColor.DarkRed;
                Console.ForegroundColor = ConsoleColor.White;
                Console.WriteLine("Close all tabs but one in all browsers then press enter.");
                Console.ResetColor();
                Console.ReadLine();
            }
            foreach (var b in _browsers) // Loop through browsers
            {
                try
                {
                    var info = new ProcessStartInfo(b, url);
                    Process.Start(info); // Start url in this browser
                    Thread.Sleep(r.Next(100, 1000)); // Sleep 100 ms - 1 s
                }
                catch
                {
                }
            }
            Thread.Sleep(r.Next(2000, 5000)); // Sleep 2 - 5 seconds.
            ct++;
        }
    }

    /// <summary>
    /// Get list of top 2000 urls.
    /// </summary>
    static IEnumerable<string> GetUrls()
    {
        return File.ReadAllLines("top.txt").Where(item => item != null &&
            item.Length > 1 &&
            item[0] != '#').Select(item => "http://" + item);
    }
}

URL list. The private static method GetUrls defined near the end of the Program text returns an IEnumerable collection of the URLs specified in the Alexa top site file the author derived from the Alexa web site. It provides some preprocessing of the string URLs to improve compatibility with Safari 4.0, which requires that each argument start with "http://".

Internet Explorer

Here we note the absence of Internet Explorer 8.0, which is the latest version of the most popular web browser in the world. IE 8.0 was omitted from the test because the author could not find a way to prevent it from opening a new window on each invocation of the command. The article has enough context for useful conclusions because it shows the new process architecture in Google Chrome as well as the older architectures of Opera, Safari and Firefox.

Summary

Here we saw an experiment that tested the memory usage of Firefox 3.5 and Google Chrome 3.0, along with Safari 4.0 and Opera 10 (some pre-release versions). The memory watcher program that recorded and accumulated memory every three seconds over 19.2 minutes of intense browsing in four browsers at semi-random intervals reported figures that place Firefox 3.5 in the clear lead in memory usage. Firefox 3.5 showed the best memory efficiency in the average, maximum and final measurements.

See Misc. Articles.

© 2007-2010 Sam Allen. All rights reserved.

Dot Net Perls  Sam Allen