Tips for Optimizing Linux Memory Usage
If you ran the command line described earlier, one of your largest binaries was probably the X server. The X Window system takes a lot of memory resources.
The first question to consider is, do you really need to run X? Using the virtual consoles and selection service you can have multiple windows supporting cut & paste of text using a mouse. Particularly while performing large compiles (such as the kernel), you should consider the option of simply not running X.
There is also a windowing system called “mgr” than can be used as an alternative to X, but requires less memory.
If you decide to use X, then you can obtain replacements for some of the standard tools that require less resources. “Rxvt” is similar to xterm, but requires significantly less memory. The window manager “fvwm” will also use less resources than others, and “rclock” is a small X-based clock program. These three tools, written by Robert Nation, can make running X feasible on a machine that constantly swapped before.
How many programs do you run on the X desktop? Run “top” to see how much memory is being taken by xclock, xeyes, xload, and all those other goodies you think you need.
The “Tiny X” package, put together by Craig I. Hagan, contains the Korn shell, fvwm window manager, rxvt, rclock, X server, and the minimum of other files needed to run X. The package is small enough to fit on one 3.5" floppy disk. Also included are some useful notes on saving memory under X.
With the techniques described here, you can run small X applications reasonably well on a machine with only 4 megabytes of memory. On machines with more memory, the same methods will allow you to run larger applications and free up memory to use for disk buffering.
By combining the techniques I've described, the net effect on system performance can be well worth the effort. I encourage you to experiment, and along the way you'll almost certainly learn something new.
The software mentioned in this article is available on a number of Internet archive sites, including sunsite.unc.edu and tsx-11.mit.edu. I suggest getting a copy of the Linux Software Map to help track down the software you need.
If you want to learn more about how the Linux kernel implements memory management, check out ”The Linux Kernel Hackers' Guide“, by Michael K. Johnson, part of the Linux documentation project. Appendix A of that document includes an extensive bibliography of books covering operating system concepts in general.
”How to Maximize the Performance of X" is periodically posted to the Usenet newsgroup news.answers, and contains more ideas for improving X performance on small systems.
- The Ubuntu Conspiracy
- A First Look at IBM's New Linux Servers
- Vigilante Malware
- Disney's Linux Light Bulbs (Not a "Luxo Jr." Reboot)
- Vagrant Simplified
- Libreboot on an X60, Part I: the Setup
- System Status as SMS Text Messages
- Dealing with Boundary Issues
- Bluetooth Hacks
- Non-Linux FOSS: Code Your Way To Victory!