Tuesday, March 24, 2009

FireFox Memory Madness.

So, FireFox....It's alright.

Problem:
FireFox, will occasionally - depending on sites I browse to, shit all over my system and begin consuming memory indefinitely until the systems because inoperable and I am forced to cause a hard reboot or force my session to restart (ctrl+alt+shift+back space).

Browser details:
Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.0.7) Gecko/2009030422 Ubuntu/8.10 (intrepid) Firefox/3.0.7

OS Details uname -a:
Linux Moneque 2.6.27-9-generic #1 SMP Thu Nov 20 21:57:00 UTC 2008 i686 GNU/Linux

A Solution:
Use ulimit to limit the amount of memory Fire Fox can access.
https://bugs.launchpad.net/firefox/+bug/314424

You'll need to open up the firefox startup file, I believe you'll need sudo/super-user privileges to do so, the file is found here /usr/lib/firefox-3.0.5/firefox.sh your version name may be different. In my case the command for opening from the terminal was:


sudo gedit /usr/lib/firefox-3.0.7/firefox.sh


Some where near the top of the file, after the comments, add the following block of text. Do not add it between brackets ( { } ) but in its own space


# Limiting virtual address space, data segment, and resident memory
ulimit -d 500000
ulimit -v 500000
ulimit -m 250000


Your finished file may look something like this:

....
....
# Fabien Tassin
# Steve Langasek
# License: GPLv2 or later

# Limiting virtual address space, data segment, and resident memory
ulimit -d 1300000
ulimit -v 1300000
ulimit -m 1300000


MOZDIR=$HOME/.mozilla
LIBDIR=/usr/lib/firefox-3.0.7
APPVER=3.0
....
....



the numbers here are the maximum amount of memory firefox will be allowed to use. I couldn't get a concrete understanding but I believe this limitation is enforced by the kernel, no way for FF to get around it....The numbers are in Kilobytes so 1300000 is roughly 1.2Gigabytes or 1,269MB (I party hard). You may need to change these numbers to reflect your system. You can get good numbers from the Google converter: http://www.google.com/search?hl=en&q=1300000KB+in+GB&btnG=Google+Search&aq=f&oq=

I suspect the average user may want to use about 300MB or so, that would be about 300000kb


ulimit -d 300000
ulimit -v 300000
ulimit -m 300000


After you have saved the file restart firefox and you should be good to go.

No comments:

Post a Comment