Recent browser memory usage benchmark from Dot Net Perls is generating buzz (as such things do). I tried to stay away (as I do) but Martin’s post on discrepancies in it from incorrect measuring of multithreaded Chrome mentioned Opera memory consumption settings and got me interested.
Since original test used beta versions of browsers and I am not too good with C# in which code was provided – I coded my own version in AutoIt.
Disclaimer
Browser memory consumption is very vague metric because of differences between actively using memory and wasting it that are frankly impossible to determine on end-user distribution. Still it can be interesting insight in how browsers work and affected by different settings.
Counting memory
It is inconvenient to do task all in one program so first script waits for launch of specific process and then counts and logs its memory usage every three seconds.
$process=$CmdLine[1]
$log=@ScriptDir&"\"&$process&".log"
Do
Sleep(100)
Until ProcessExists($process)
While ProcessExists($process)
$memory=ProcessGetStats($process)
$memory=$memory[0]
FileWriteLine($log,$memory)
Sleep(3000)
WEnd
Since it will be called from main script – it gets name of process to watch as command line parameter.
Opening sites
As original test suggested I took top 150 sites from list provided by Alexa. So much Google, so much porn. Ahem.
Opt("WinTitleMatchMode",2)
$list="d:\list.txt"
$browser="c:\FirefoxPortable\FirefoxPortable.exe"
$path="c:\FirefoxPortable\"
$process="firefox.exe"
$window="Firefox"
$list=FileRead($list)
$list=StringSplit($list,@CRLF,1)
Setting up some variables needed and reading text file with links into array.
ShellExecute(@ScriptDir&"\memory.exe",$process)
ShellExecute($browser,"",$path)
Sleep(1000*30)
$s=0
For $i=1 To 150
ShellExecute($list[$i])
Sleep(Random(1000,10000))
$s+=1
If $s=30 Then
WinActivate($window)
WinWaitActive($window)
For $j=0 To 29
Send("^w")
Sleep(Random(100,1000))
Next
$s=0
EndIf
Next
Sleep(1000*30)
WinClose($window)
Exit
Launch memory script (compiled), then browser itself and let it settle in.
Then main loop starts that opens links in new tabs (with random 1-10s pause between them) and closes all tabs every thirty links.
Then there is cool off period and browser is closed.
Test bed
I was lazy to set up complete clean environment on virtual machine. So I settled for:
- my home desktop – Pentium Dual Core 2.6GHz, 2Gb RAM;
- Opera@USB 9.64, clean install:
- one run with automatic (default) memory cache;
- one run with 60Mb memory cache;
- Firefox Portable 3.0.11. clean install.
I was mostly interested in different Opera settings so Firefox is just for company. Tests run full auto while I had productive Tetris rounds on my N810.
Results
Opera auto | Opera 60MB | Firefox | |
Average, MB | 260,6 | 171,2 | 135,82 |
Maximum, MB | 453,84 | 303,89 | 245,06 |
Overall
Huge difference between Opera on automatic and manual settings clearly show that high memory consumption it displays is not because of wasted memory. By default Opera uses very aggressive memory cache to keep a lot of data in memory so it can be quickly recalled as needed.
Even on largest fixed setting memory consumption instantly falls close to Firefox levels.
Script https://www.rarst.net/script/memory.au3
Script https://www.rarst.net/script/browsers.au3
Jonny #
Rarst #
Abhinav K #
Abhinav #
Rarst #
Chocobito #
Rarst #
Jonny #
Rarst #
Nihar #
Rarst #
Ben #
Rarst #
Common browser experience | Rarst.net #
Steve #