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


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...


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.

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

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:

To enable memory usage minimization for firefox, only remove the # and save the file. The contents of the file would become:

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:

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[...]]]
  • -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!

How to use more than 4GB of RAM with 32-bits Windows OS?

Actually, I am still running the good old Windows XP 32-bits system on my 4GB RAM laptop. And as some of you may know, Windows 32-bits OS can use a maximum of 4GB of RAM due to the addressing space constraint.

In practice, my Windows XP only allows me to use a maximum of 3GB of RAM for my programs, while 1GB is restricted to the kernel. This, given that I enabled the PAE (Physical Address Extension) option for the kernel.

Anyway, I found a solution that enables me to use the whole 4GB for my applications, and that enables in general to use even more than 4GB of RAM with a 32-Bits Windows OS.

The trick is easy. Among the memories used by the system there is the RAM and the disk swap space (commonly C:\PageFile.sys) and other types also. I will let Windows use the 3GB of RAM as normal. Then I will make it use the last 1GB of RAM as a swap space, as if it was on disk. But to do this I will have to create a RAMDisk. A RAM disk is a virtual volatile disk that exist only in RAM. This enables me to regain the 1GB RAM space and use it for memory pagination operations. So nothing is lost.

To do so, I use a program called VSuite Ramdisk. This program enables me to create a new virtual disk drive in "My Computer" folder that enables me to access the 1GB RAM space that the OS cannot access natively.

You can download the program from here. The free edition does well. Once installed, you have to configure it to make the new RAM drive. Here is how:

1. Open the program.
2. Click on "Options" on the left tab bar.
3. Check the option "Enable OS Invisible Physical Memory".
4. Click on "Ramdisk" on the left tab bar.
5. Look at the option "Use OS Invisible Memory", next to it there is the total space of the RAM the 32-bits OS cannot use. Note down that number, I will called it OSIRS.
6. Choose the options for the new RAM drive. Personally I chose:
- Disk Size: 892MB
- Drive Letter: M:
- File System: FAT. You will need to use FAT32 if you have 6GB or more of RAM.
- Volume Label: RAMDISK
The rest of the options I kept for the default.
7. Click on "Add" button.
8. Click on "Exit" button.

Now you have a new drive in your computer called RAMDISK accessible as M:. Because of its volatile nature, this drive does not retain any files written into it once the computer is rebooted or shutdown.

Now, we will tell Windows to use our new drive as a container for its swap space. Here is the procedure:
1. Right click on "My Computer" and select "Properties".
2. Click on "Advanced" tab.
3. Click on "Settings" button inside "Performance" frame.
4. Click on "Advanced" tab.
5. Click on "Change" button inside "Virtual Memory" frame.
6. Select "M: RAMDISK" from the list.
7. Choose the option "Custom size" inside "Paging file size for selected drive" frame.
8. In "Initial size (MB)", type the number OSIRS minus 6. For example, in my case I type "886".
9. Type the same number in the text field "Maximum size (MB)".
10. Click the button "Set".
11. Click the button "OK".
12. Click the button "OK".
13. Click the button "OK".

Now, Windows will use the RAM disk every time it runs out of those 3GB RAM memory. Windows will not tell you that it uses the full 4GB (or maybe more in your case), but it will effectively do it.

Windows is still configured to use hard disk space to do paging operations, and because of this, some might argue that Windows might use the hard disk to swap pages of memory, instead of the RAM disk, which makes our trick meaningless, but here some ways to get around it:
1. You can remove the swap space from all other drives except the RAM disk. This will make dead sure Windows will use the RAM disk for memory page swapping. But this limits the virtual memory size to exactly 4GB, and in deed disables disk paging. This is not recommended.
2. Reduce the disk space used on other drives. This is my adopted solution. I limit Windows to only 1GB of hard disk space (on C:) in addition to the 886MB space of the RAM drive. This gives me about 5GB of virtual memory. By experience, I have never got in an out of memory situation since I bought my laptop (This means about 5 months of usage without a single out of memory situation). This proves that the 5GB are really sufficient for my jobs. The amount of hard disk space you need depends on your set of applications and how you use them. You can test for yourself to find a suitable configuration, you can always higher that size given that you have free space on the hard disk.

That's all. Thank you for your attention. I wish I have given something useful.

Installing ATI Proprietary Linux Driver (fglrx) on Debian Lenny 5.0 Stable 64 bits

I am one of those unlucky peoples who happen to own a laptop equipped with an ATI graphic card, while being strongly attached to the open source world...

Yes, again, and the fight just continues between open source world (Linux, BSD, ...) and the ATI for its graphic chipset driver.

I am not going to reenter all that history. In brief, I have successfully installed the fglrx driver version 10.10 (the ATI Proprietary graphic chipset driver) on my laptop running the Linux Debian 5.0 Lenny Stable 64 bits.

Let's put it in perspective: I did that in 16 November 2010. In that day, the 10.10 version of fglrx is experimental, but not yet available in the experimental version of Debian. It may seem weired to install an experimental driver on the stable version of the OS, but I can say I had no choice. My graphic card was only supported starting from that version of fglrx. Yet I still stick to the reliable stable version of the Debian OS.

I am presenting this experience to the world because I find it useful for some of you, a bit like me. And I think it can help some others to install fglrx on their machines, if they have to. I made some bash scripts that automate the installation to some extent. But I want to show what they do first.

Hereafter are the general steps needed to install the fglrx driver. These are only meant to be understood, not to perfectly follow, because I will give some scripts that automate these actions just later.

1. Download the ATI Proprietary Linux Driver package. This got me the file.

2. Remove all traces of ATI drivers using the package manager.
apt-get purge fglrx-driver fglrx-driver-dev fglrx-atieventsd fglrx-modules fglrx-kernel-src fglrx-control fglrx-glx fglrx-amdcccle fglrx-kernel fglrx-glx-ia32 fglrx-source

3. Extract into a directory fglrx-10-10.
"./" --extract "./fglrx-10-10"

4. Correct the internal structure of the fglrx installer package:
These steps are the fruit of hours of debugging efforts I did to figure out how to make the fglrx installer generate correct debian packages for me.

4.1. Create some directories.
The structure of the extracted installer files is not complete for a 64 bits system. So I corrected that.

4.2. Copy some files.
Some files needed to be copied to different locations inside the installer directory, in order to be installed in the right places when the packages are built.

4.3. Alter some files.
Some configuration files and scripts needed some changes to install the needed files and to make the correct links to the shared libraries when installed on the system.

5. Create the debian packages (.deb) from the extracted patched files.
./ 10.10 --buildpkg Debian/lenny

6. Install the generated packages.
dpkg -i fglrx-driver*.deb
dpkg -i fglrx*.deb

7. Remove the open source ATI drivers available with Xorg.
apt-get purge xserver-xorg-video-ati

8. Patch some Linux source files.
This is required to solve a compatibility issue with fglrx and linux kernel API.
The issue is a change in the name of a function in the linux kernel, which is not taken into account by the developers of fglrx. The change I do does not really hurt the linux kernel itself, as all I am doing is adding a new function that is the exact copy of another one.

9. Build and install the fglrx kernel driver.
This will build the fglrx kernel module which enables the 3D acceleration of the graphic card.

10. Ensure that the fglrx kernel driver is loaded as a kernel module.
This is a final check to ensure the fglrx module has been installed and loaded into the kernel:
modprobe -l | grep fglrx

11. Configure the Xorg server to use fglrx driver.
First we have to stop gdm (GNOME Desktop Manager):
invoke-rc.d gdm stop

Then we generate the Xorg configuration that uses fglrx for X:
aticonfig --initial=dual-head

Finally we start gdm:
invoke-rc.d gdm start

12. Pin fglrx driver in the package manager to disallow any further automatic upgrades.
I don't actually provide the script needed to do this, as I easily do it using Synaptic Package Manager.

Here are the files needed. Just download this archive, extract it and put it in the same directory as the file. It will contain:

The scripts should be run as root from a real TTY (Alt-Ctrl-F2) as they don't expect X to be running all their lifetime. The run order is the following:

./make_packages 10 10

I am here for your comments or questions, don't hesitate.
I wish I added something to the community. Enjoy!

A study on Plug-in system concept

A study on Plug-in system concept


  • Plug-in: A program that forms a part of another program. It is designed to depend on the Plug-in server. It communicates with the server thru its Plug-in API.
  • Plug-in server: A program designed to manage plug-ins.
  • Plug-in API: A programming interface that connects the plug-in to the server.
  • Server environment: Global variables or constants defined by the server that are part of the plug-in API. They are common to all plug-ins.
  • Plug-in environment: Variables or constants defined by the server that are part of the plug-in API. They are specific to each plug-in.



  • Self identification is optional unless required by the server.
  • After receiving unloading event, a plug-in must free all its associated resources and effectively unload from memory without leaving any executing code after it.
  • Can provide user interaction methods only if the server allows it.
  • It must be able to unload it self before the server does it. If this is wanted, the server must be notified about this.

Plug-in Server

  • Self identification.
  • Registration and removal handling.
  • Loading and unloading handling.
  • Providing the Plug-in API interface.
  • Maintaining compatibility in API interfaces.
  • Sending vital plug-in events: Loading and unloading.
  • If it defines environments variables, it must handle mutual access to them by the plug-ins.

Plug-in API

  • Interface can be of any type. Examples: DLL exported functions, DLL exported C++ classes, COM classes, IPC technologies (named pipes, sockets, RPC...), .NET interoperability, Java classes...
  • Different interfaces types may provide different capabilities but a basic level of capabilities must be shared by all theses.
  • Programming language independent, but may be binary dependent.
  • Error communicating methods are defined by the server.

Server environment

  • If a plug-in set them, other plug-ins must be notified.
  • A plug-in receiving environment-change-notification must be able to refuse the change or unload it self returning error to the server.
  • Each server environment entry must have a default value before loading the first plug-in.

General recommandations about performance

Plug-in API

  • Provide minimal interaction between the server and the plug-in.
  • Be simple and extendable. If advanced functionalities are required, they may be specified using special API entries or flags.
  • Provide a way to set environment entries in batch mode.
  • DLLs are very efficient as an interface so use them when you can, this implies using any DLL-based technology (DLL exported functions, DLL exported C++ classes, in-process COM classes).
  • IPC technologies provide other sets of options for the plug-in (executing code out-of-process, networking, operating system independency, possibility of using other programming languages…) but they are not recommended.
    • Networking implemented transparently in IPC technologies (socket, RPC using socket, COM Class Proxies) slows down significantly interaction performance and should be handled specifically and with care.
    • Executing out-of-process code requires explicit synchronization to be handled by the plug-in and adds much checking points before each interaction with the server and many features cannot be implemented using IPC communications.
    • Some older programming languages produce only executable modules (EXE) so they will oblige you to use IPC.
    • Operating system independency is very rarely required and it's very complex due to conversions needed before and after each single interaction and network management between both operating systems.
  • .NET and Java plug-ins are not recommended because loading a single module containing .NET or Java code would require the server to load a big part of the .NET framework or the Java Virtual Machine. This recommendation may be obsolete in future if the operating system is based on the .NET framework or the machine contains Java Microprocessor, in both cases loading the considered plug-in will be very efficient.
  • If a plug-in module must be registered somehow to run properly (VB6 modules, .NET assemblies, Java applets…) it's recommended to make an installation program to this plug-in.

Plug-in Server

  • Make plug-ins interaction in separate threads in order to maintain a responsive user interface and to take advantage of multithreading technologies.
  • If a server must make plug-in interaction in shared threads, it must provide a user interface showing that a plug-in interaction is in progress if such an interaction takes much time. This not recommended as it implies the ability of the user to "cancel" interaction which may be hard to implement or inefficient.
  • Use of structure versioning and flag masking is recommended for performance and compatibility


  • Avoid interaction with the server in loops.
  • If user interaction is designed, it should be separated from server interaction to maintain user interface responsiveness.
  • If multiple plug-ins are designed to the server, and the server supports multiple plug-ins in one module, then designing all the plug-ins in the same module is recommended in most cases.

General recommandations about security

  • Catch error cases from the plug-ins including fatal or unexpected errors. Example: SEH exceptions, hardware exceptions...
  • Using GUID to identify the plug-ins avoids collision between them.
  • If you have to choose between compiled, interpreted and script code, use compiled or interpreted when possible. Scripts present many security risks.

The trick to the Graceful Exit

There's a trick to the Graceful Exit.
It begins with the vision to recognize when a job, a life stage, a relationship is over -- and to let go.
It means leaving what's over without denying its validity or its past importance in our lives.
It involves a sense of future, a belief that every exit line is an entry, that we are moving on, rather than out.
The trick of retiring well may be the trick of living well.
It's hard to recognize that life isn't a holding action, but a process.
It's hard to learn that we don't leave the best parts of ourselves behind, back in the dugout or the office.
We own what we learned back there.
The experiences and the growth are grafted onto our lives.
And when we exit, we can take ourselves along -- quite gracefully...

Grand Corps Malade - Mental

S'il y a bien une idée qui rassemble, une pensée qu'est pas toute neuve
C'est que quel que soit ton parcours, tu rencontres de belles épreuves.

La vie c'est Mister Hyde, pas seulement Docteur Jekyll.
J'ai vu le film depuis longtemps, la vie n'est pas un long fleuve tranquille.

T'as qu'à voir les réactions d'un nouveau né à l'hôpital
S'il chiale si fort c'est qu'il comprend que souvent la vie va lui faire mal.

Y'a des rires, y'a des pleurs, y'a des bas, y'a des hauts.
Y'a des soleils et des orages et je te parle pas que de météo.

On vit dans un labyrinthe et y a des pièges à chaque virage
A nous de les esquiver et de pas calculer les mirages.

Mais le destin est un farceur, on peut tomber à chaque instant
Pour l'affronter, faut du cœur, et un mental de résistant.

J'ai des cicatrices plein la peau, et quelques unes dans mes souvenirs
Y'a des rescapés partout, j'suis un exemple, ça va sans dire
Ca doit se sentir, faut pas se mentir, la vie c'est .aussi la guérison
Après la foudre, prends toi en main et redessine ton horizon.

Y'a des tempêtes sans visage où on doit se battre contre le pire
Personne n'y échappe Rouda c'est pas toi qui vas me contredire
C'est l'ultime épreuve où tu affrontes la pire souffrance morale
Quand la peine rejoint l’impuissance pour la plus triste des chorales.

J'ai vu des drames à cœur ouvert j'ai vu des gens qui s'accrochent
Ce qui est bien avec le drame, c'est que tu le partages avec tes proches
Pour les miens il est peut-être l'heure de m'arrêter un court instant
Pour les remercier d'avoir du cœur et un mental de résistant.

La vie est aussi perverse, ce que tu désires elle l’a caché
Elle te le donnera pas tout cuit. il va falloir aller le chercher.

Du coup ce qu'on a, on le mérite, au hasard on a rien piqué
Et si t'as pas compris, va voir mes potes ils vont t'expliquer.

Jacky, tu m'as dit que l'ascenseur social était bloqué
Toi t'es allé chez Otis et le réparateur tu l'as braqué
Sans craquer, sans rémission, t'as affronté de vraies missions
Tu m'as montré qu'avoir du mental. c'est aussi avoir de l'ambition.

Y'a pas de chemin facile, Brahim t'as rien demandé à personne
T’as tout construit de tes mains et y'a pas que moi que tu impressionnes.

Toi Sami t'es notre moteur parce que tu sais depuis longtemps
Que pour que ca chémar il faut du cœur et un mental de résistant.

Je crois qu'on a tous une bonne étoile sauf que des fois elle est bien, planquée
Certaines même plus que d'autres, il faut aller les débusquer.

Parfois ça prend du temps quand tu fais trois fois le tour du ciel
Mais si tu cherches c'est que tu avances, à mon avis c'est l'essentiel.

Je fais partie de ceux qui pensent qu'y a pas de barrière infranchissable
Il faut y croire un peu, y'a bien des fleurs qui poussent dans le sable
Et' c’est quand tu te bats qu'il y a de belles victoires que tu peux arracher
Comme se relever avec une moelle épinière en papier mâché.

Je n'apprends rien à personne, tu es vivant tu sais ce que c'est.
Vivre c'est accepter la douleur, les échecs et les décès
Mais c'est aussi plein de bonheur, on va le trouver en insistant.
Et pour ça, faut du cœur et un mental de résistant.

Idir, La pluie

Tant de pluie tout à coup sur nos fronts, sur nos champs, nos maisons.
Un déluge, ici l'orage en cette saison, quelle en est la raison?
Est-ce pour noyer tous nos parjures? ou laver nos blessures?
Est-ce pour des moissons, des terreaux plus fertils?
Est-ce pour les détruire?

Pourquoi cette pluie? Pourquoi? Est-ce un message, est-ce un cri du ciel?
J'ai froid mon pays, j'ai froid. As-tu perdu les rayons de ton soleil?
Pourquoi cette pluie? Pourquoi? Est-ce un bienfait? Est-ce pour nous punir?
J'ai froid mon pays, j'ai froid. Faut-il le feter ou bien le maudir?

J'ai cherché dans le livre qui sait, au creu de ses versets.
J'y ai lu: "Cherche les réponses à ta question. Cherche le trait d'union".
Une mendiante sur mon chemin, que fais-tu dans la rue?
Mes fils et mon mari sont partis un matin, aucun n'est revenu...

Pourquoi cette pluie? Pourquoi? Cette eau, ces nuages qui nous étonnent?
Elle dit cette pluie:
"Tu vois, ce sont des pleurs pour les yeux des Hommes.
C'est pour vous donner des larmes, depuis trop longtemps elles ont séché.
Les Hommes n'oublient pas les armes quand ils ne savent plus pleurer..."

Coule pluie, coule sur nos fronts...