How to Reduce Linux memory overhead

Source: Internet
Author: User
Article Title: How to Reduce Linux memory overhead. Linux is a technology channel of the IT lab in China. Includes basic categories such as desktop applications, Linux system management, kernel research, embedded systems, and open source.
Insufficient physical memory may seriously affect Linux®Performance. In this article, we will learn how to accurately measure the amount of memory used by the Linux system. We will also take the Ubuntu system as an example to learn practical suggestions on reducing memory requirements.

Linux is more popular than Microsoft®Windows®Therefore, it can be executed well on less advanced hardware. For those who are still using machines in the Windows 98 age, the latest and most outstanding software (especially security patches) no longer support these machines, therefore, this performance advantage makes Linux an attractive upgrade product.

However, the truth is that although the Linux kernel can still be configured to a reasonable size and efficiency, many Linux desktop environments (such as KDE and GNOME) added many features. Therefore, when most releases are installed on older hardware by default, the performance provided is not first-class. This is also true for many modern applications, such as Web browsers like Firefox and office suites like OpenOffice, but they try to run these programs on machines with only 128 MB of RAM, it may be a very painful experience!

What should I do? Discard all old hardware and upgrade it? Or is the Linux release version installed around 1995? (If you decide to follow this path, I remember using Linux-FT is a good experience .)

Don't worry: many years ago, people in the Linux community have realized this problem. A major feature of the Linux kernel and the release version (some people like to say this great feature) is that it can be customized. This article describes how to reduce Linux systems to achieve better performance on Small-capacity hardware.

Memory Function

In most cases, the most important factor in the performance of the desktop operating system is the amount of memory available to the system. Although it works well with a fast processor, if there is not enough physical memory to ensure that the processor is always used well, the system may spend a lot of time exchanging data between the physical memory and the swap space (this is called Disk jitter), and the CPU is idle most of the time. Therefore, for older systems, adding additional memory is usually the easiest way to improve performance. However, this method is unlikely to be determined for many reasons, such as the lack of free slots. For some systems (especially laptops or RAMBUS-based systems), there is a lack of affordable RAM, it's easy to understand that you don't want to spend more money on an expired system.

If you cannot or are unwilling to upgrade RAM, it is best to reduce the RAM requirements on the system. This article will show five simple steps to create a memory paradise for Linux machines.

Step 1: select the correct desktop environment

The only important choice is the Linux release and desktop environment (DE) to be installed ). Although this is a completely different choice, the choice of the release may affect the choice of DE. Although nothing can block you from installing software on the system, such as installing Fluxbox on Ubuntu, you will find that if you simply use the default DE that comes with the release, everything will be much easier.

In this article, the goal is to find a simple desktop-oriented release for new users. I started with Ubuntu 6.10 and launched it with GNOME 2.16.

For basic systems, I chose an old machine with a 800 MHz processor and 256 MB RAM. I will perform two tests, one with all 256 MB RAM for normal boot, and one with mem = 128 M attached to the kernel line, which forces the kernel to recognize only 128 MB of physical memory. In this way, you can effectively Test Machines of 256 MB and 128 MB without having to use another physical machine (or repeatedly plugging the memory from the machine ). This kernel line option is enough to simulate the behavior of a 128 MB machine. Note that if there is only 128 MB of memory, other problems may occur. For example, to use Ubuntu, you must use an installation disk that is different from a general machine disk. It is specially prepared for machines with less than 192 mb ram.

To understand the basic level of memory usage, boot the system, log on to the desktop system, and start a terminal (in the content below this article, I call this setting basic level (base level). Then I use the free command to check the amount of free memory in the system. The result is shown in Listing 1.


Listing 1. Basic usage level of Ubuntu on 256 MB machines
ubuntu # free             total       used       free     shared    buffers     cachedMem:        255988     231704      24284          0       6432     139292-/+ buffers/cache:      85980     170008Swap:       746980          0     746980

The first line indicates that 256 MB of RAM is 231 MB "in use ". The next line tells us that although 231 MB of memory is in use, the application only uses 86 MB of memory, and the buffer and cache use the remaining memory.

To evaluate the performance, the most important part in this list is the Swap line. It tells us that there is no Swap space currently, which means there is no real memory problem. The system can now load all the physical memory instead of using a slow disk-based swap space.

Then, to understand the daily usage of the system, start a Web browser (Firefox 2.0) and use it to open developerWorks and connect the instant messaging client (Gaim) to MSN, use the File Manager to browse folders and open a large Microsoft Word file in OpenOffice. (In the rest of this article, this setting is called light usage level ).)

Once these are successfully loaded, the free command is shown in Listing 2.


Listing 2. Ubuntu's lightweight usage level on 256 MB machines
ubuntu # free             total       used       free     shared    buffers     cachedMem:        255988     252196       3792          0      21276      87500-/+ buffers/cache:     143420     112568Swap:       746980      18676     728304

The memory is slightly changed. Now the application uses 143 MB of physical memory, and the rest of the memory is occupied by the buffer. In addition, the system uses 18 MB of swap space. In this lightweight office task, the system availability usually looks good, but there is no space for development, and more operations may not be required, for example, editing a huge number of digital photos or video files, because the system will soon stop processing.

To understand the execution of the system in 128 MB, I rebooted the system and added the mem = 128 M option to the kernel line, as I described earlier. The result of using 128 mb ram is shown in listing 3, which is similar to the basic usage level of Listing 1.


Listing 3. Basic usage of Ubuntu on 128 MB machines
ubuntu # free             total       used       free     shared    buffers     cachedMem:        126100     121464       4636          0       1636      37000-/+ buffers/cache:      82828      43272Swap:       746980      17924     729056

We can see that only 128 MB of memory is used, and the swap space has been used, and no operations have actually been performed.

The results of starting the same group of applications are shown in Listing 4.


Listing 4. Ubuntu's lightweight usage level on 128 MB machines
ubuntu # free             total       used       free     shared    buffers     cachedMem:        126100     123608       2492          0        392      51208-/+ buffers/cache:      72008      54092Swap:       746980      98452     648528

 

[1] [2] [3] Next page

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.