How to save memory
|This page is meant as a collection of information on how to save memory to make Linux work reasonable on older system with limited amount of RAM.
Most distributions nowadays don't take much care about it anymore, so there are a lot of things you can do to save memory. To get a smoothly working linux environment on a low memory machine you will need to conciously choose a lot of aspects of your system, most importantly the graphical environment, desktop environment and applications. This page provides detailed information about these various optimization possibilities.
Alternative graphical environments
Streamlining the desktop environment
The common Desktop environments GNOME and KDE are, in their modern state, focused more on features, integration, and beauty rather than on resource saving. Understandable, but running Linux on an older ThinkPad with limited RAM requires conscious and sensitive resource usage more than anything else. The good thing about Linux is that a lot of things stay adjustable and customizable. So lets see what we can do about desktops.
One of the most important things is to decide for one graphical widget library and stick with that when you are choosing your desktop environment and applications. Having several toolkits in use means more libraries being loaded and hence more memory being used by those. Possibilities are:
- FOX toolkit
- GNUstep toolkit
- GTK (not recommended, use GTK 2 if possible)
- GTK 2
- Lesstif / OpenMotif
- WINGs (kind of a lightweight GNUstep toolkit, provided by the WindowMaker developers)
- X Toolkit
Of those, at current state, there are enough applications for the X Toolkit, GTK, GTK 2 and QT to provide you with a solution for every task you should want.
It's like with humans, the worst feature is in most cases also the best one. For GNOME it is probably the many little parts it consists of. Makes it hard to install, but enables one to customize the installation. So, the first thing you should do to streamline GNOME is not to launch it. Sound stupid? Well, lets have a look.
GNOME is basically a set of libraries built around the GTK+ libs and extending its functionality. Add some nice little applications, a session manager, a panel, beautiful icons, and some other stuff and you have GNOME as you know it. Reversing those additions is what you can do to use GNOME applications on a machine that this desktop environment would normally take your nerves on.
The GNOME panel, the session manager, the desktop manager and the window manager are all parts of GNOME that eat a lot of memory for something that others can do in a maybe little less beautiful but much more resource saving way. So first off configure your login manager not to launch gnome-session at login. If you are using GDM this is quite straight forward, you just need to add a different session script, launching your favorite window manager. See the list below and pick one, lets say i.e. WindowMaker. WindowMaker uses a desktop menu, a dock and a notification area to provide you with an organized way of launching applications and iconfying running ones. So we don't need a panel anymore. Also, think if you really need icons on your desktop. If you do, think about using something like ROX filer instead of nautilus for that. In any case, tell nautilus not to manage the desktop by default by unchecking the according setting within gconf-editor. To keep GNOME applications happy we would need to have gconf and gnome-settings-manager running at every session start. One way to do this is to either include them in your new session script. They both need to be running to make GNOME applications realize their settings properly.
Alternative Desktop Environments
First of all, it is important to notice that GNOME and KDE are not the only Desktop Environments around. Other complete (featuring most of: window management, session management, desktop management, file management and panel) desktop environments are:
- XFCE uses GTK 2
- Equinox Desktop Environment uses eFLTK, a modified version of FLTK
- AntiRight Desktop Environment uses LessTif / OpenMotif
- FOX Desktop Environment uses FOX Toolkit
- GNUstep provides it's own toolkit
But also, some Window Managers exceed the task of managing windows towards providing a functional workbench. See below for a list.
Building your own Desktop
If you want to build your own customized desktop, a good start is choosing the window manager of your liking.
Here's a list of some of them:
- including basic Desktop Environment functionality
- the NextStep alike ones
- the Blackbox-like ones
- pure WindowManagers
Another thing that especially users coming to Linux from the Windows world would probably like is a Panel or Taskbar.
Here's a collection of independant low resource panels:
- F***ing Small Panel (doesn't use any toolkit)
- HPanel (doesn't use any toolkit)
- fbpanel (depends on GTK 2)
- Perl Panel (depends on GTK 2, gnomevfs, perl)
- GKrellM (depends on GTK 2, flexible plugin based skinable vertical panel)
Then, the next thing you might be looking for is how to get icons onto your desktop. Usually this is done by the file manager who displays the content of a special directory as icons on the desktop. See the File Manager section to follow this approach.
However, you might decide for a really lightwight file manager which doesn't offer this feature. In that case all hope is not lost, for there are also special programs specialized in desktop icon management. Such are:
- iDesk (recent versions need imlib2 only)
File Managers are the fourth really important compontent of a desktop environment. There are plenty out their ranging from resource hugs to really lightweight and slim ones.
File Managers come with three distinct general user interface approaches: the two pane gui, the spacial and the browser gui. The browser gui is the one the Windows Explorer starting from Windows 2000 uses as well as earlier versions of Nautilus. The spacial view is the one known from Windows 95 and more recent versions of Nautilus. The two pane view is know to many from Norten Commander, Directory Opus or your favorite FTP client.
The following list provides an overview.
- Fast Light File Manager (spacial gui)
- FOX toolkit
- X File Explorer (browser and two pane gui)
- GTK 2
- ROX Filer (highly productive spacial gui, incl. panel and desktop icon management)
- Filer (browser and two pane gui, requires Perl)
- XFFM (browser and spacial gui, requires some XFCE libs)
- Logical Desktop (browser gui, actually a very special approach)
- Tux Commander (two pane gui)
- emelFM2 (two pane gui with full customizable menu and toolbar, the best for power users)
- Thunar (requires some XFCE libs)
- PCMan File Manager (An extremly fast and lightweight file manager which features tabbed browsing and user-friendly interface. Requires GTK+ version 2.8.x)
- Xplore (browser gui with productive 4 pane concept)
- QT 2
- BF-Commander (two pane gui)
- Beesoft Commander (fast & easy two panel file manager, like Norton Commander)
- X-Files (two pane gui)
- X Toolkit
- 3D Filemanagers
This is highly dependent on the way you use your browser, it's often worth it to try out all and just track general memory usage. Remember that top and ps don't report correct memory usage, track totals only.
Firefox is graphical web browser. One can install features like AdBlock and FlashClicktoplay which will decrease memory and processor usage by hiding Flash and Java -adverts.
Opera is graphical web browser. You can easily enable/disable plug-ins and java (press F12) and decrease memory usage. Opera uses QT as toolkit, so you may shave off some Mbytes off memory usage by using dynamically linked version if you use KDE.
Konqueror is graphical web browser. It's integrated with KDE and has several advanced features (esp. ca. KDE 3.5). You may save some megabytes by using it instead of other browsers when using KDE. It's not necessarily heavy even when used without running KDE.
Dillo is minimalistic and very small graphical web browser.
elinks/lynx are both text mode web browsers. elinks handles tables and formatting much nicer than lynx. Both go very easy on memory footprint.
Disabling unneeded system deamons
Another thing you can do to improve performance is to get rid of unneaded system daemons launched from your init scripts. Disable them by using the according configuration interface of your distro or by deleting links in the according runlevel directories (usually in
Daemons you usually don't need:
- httpd (Apache web server)
- mysqld (MySQL database server)
- smbd (SMB windows filesharing server)
- pppd (PPP server for connections through modems and serial lines)
You can also try to optimize memory usage by making sure that you have as little as possible of your filesystem residing in RAM. To do this make sure that the following mount points are set to reside on your harddisk in /etc/fstab.
- /dev (not possible if you use udev)
Also make sure that you mount filesystems with extensive usage with noatime parameter (mount -o remount,ro /...), which disabled access time writes every time you access some file. Note that many incremental backups needs atime to work, such backups will then behave like full backup everytime. This depends on backup systems.
When using Debian/Ubuntu/other derivative, use aptitude as package manager, and use it as soon as possible. Use it and only it to install and remove packages.
One of its most useful features is that it tracks packages you install and marks packages installed via dependency as such, so when you remove a package that is no longer used, or package updates and doesn't use a library anymore, that dependency will get uninstalled.
You can mark packages installed as automatically installed by hitting 'M' (uppercase m), it will be marked for deinstallation if it's not longer required.
You could also install localepurge wich will remove all unneeded locales and localized manpages for packages you install.
ntpd can occupy around 4MB of memory, which is a substantial proportion of many older systems' total. chrony is a pair of programs that replace the standard ntp and require much less memory.