You are inside a passionate computer engineer's lab...
Proceed at your own risk...

Look for something inside my Lab...

Minimize Firefox RAM Memory usage

Introduction

Today, many of you are using the Firefox browser to surf on the Internet and develop web applications, etc... Once you begin using Firefox you may realize that it consumes too much RAM which goes up to 200MB in normal usage and can reach 700MB after several hours of continuous browsing. Yet, many of us still have a 1GB laptop or even a 512MB good old desktop computer. This means that if you use Firefox to browse on such computers, your multi-tasking ability is severely reduced.

This made me decide to put in action a program that reduces RAM usage of Firefox by forcing the OS to move the memory pages of Firefox to the swap space, thus leaving much more RAM available. And I quickly made it using the C++ language.

From the end, it cuts down Firefox RAM usage to about 15MB! Cool! No?
Well, it is really cool especially when you know that it have no impact on performance because of the paging operations the OS does. This is because Firefox is a network-based program, so the major latency factor is the network speed. And the loss of CPU power put in swapping the memory pages is very thin compared to the network latency. Of course you won't probably use my program to minimize the RAM usage of Oracle Database Server...

Features

Here are some of the features:
  • Actually, the program is able to reduce RAM usage for any program, and any number of programs, not only Firefox instances.
  • It does this in a safe way (no code injection or dirty hacks).
  • It's open source under the "Simple BSD Licence".
  • It is very tiny in disk size (less than 90KB) and in RAM usage (less than 300KB).
  • It consumes almost zero CPU usage with the default configuration options.
  • It has no GUI and no Console.
  • It can be configured using command line options or a simple configuration file. I recommend using configuration file for novice users.
  • It's behavior can be customized depending on usage situations. The default options should suit most needs.
  • It is portable and consists of only one executable binary.
  • Runs on Windows 2000 or later, including XP, Vista, 7, 2003 Server, 2008 Server.
  • It has a modular design which enables source code reuse.
Download

The program is called MinimizeRAMUsage. And here I present the binaries and source files for download:
Usage

Now, to use the program, place it anywhere you want, then execute it. You will notice that nothing happens, except that a text file named "MinimizeRAMUsage.config.txt" appears next to the program in the same folder.
This file is the configuration file. Don't worry, open it using Notepad for example. You will find something like this:
timeout=400
rescan=1
#process=firefox.exe


To enable memory usage minimization for firefox, only remove the # and save the file. The contents of the file would become:
timeout=400
rescan=1
process=firefox.exe


Now execute the program again, and here it goes! You will find it in the Windows "Task Manager" and you will notice that Firefox RAM usage dropped instantly.

To make it do that automatically all the time,proceed as follows:
1. Right-Click on the MinimizeRAMUsage.exe program and choose "Create shortcut".
2. Cut the shortcut file created and paste it in the start up folder. This folder is located in: Start Menu > Programs > Startup. If you use the French version of Windows, you will find it in: Menu Démarrer > Programmes > Démarrage.
3. You're done, every time the PC boots, it will start the program and you will never ever again see Firefox consuming all your RAM memory.

Advanced usage

Now if you are an advanced or curious user, let me explain the configuration options:
  • "timeout=n" where n in an integer greater than or equal to 1. This is the duration in milliseconds that separates two periodic minimization routines done by the program. The lower it is the more you swap pages and the more free RAM you have and the higher CPU you consume. The higher it is, the lower CPU you consume and the lower free RAM you have.
  • "rescan=b" where b is one of {0, 1}. When this is 1, the program rescans the running processes every time before minimization routine, to ensure all instances of the given targets are operated on, even those started after the startup of MinimizeRAMUsage.exe. If this is 0, then the program will only operate on the instances that existed when it was started, and it will terminate its execution when all those end their execution.
  • "process=name.exe" where name.exe is the name of the executable whose RAM usage is to be minimized. This can be given several times and it operates in an incremental way.
And example of configuration file might be:
timeout=400
rescan=1
process=firefox.exe
process=chrome.exe
process=iexplore.exe


There is another way to configure this program: the command line options. The syntax is the following:
MinimizeRAMUsage.exe [-r] [-t timeout] file1.exe [file2.exe, [file3.exe[...]]]
Where:
  • -r option disables periodic rescan, which is enabled by default.
  • -t option indicates timeout in milliseconds, which is 1 by default.
  • file1.exe, file2.exe, file3.exe, ... are the executable programs to operate on.
The command line arguments overwrite the configuration file options.

That's all! I wish this come handy to some of you, as it is to me!

No comments:

Post a Comment