Linux memory management methods

Source: Internet
Author: User

If we feel very slow when using the computer, we will check the memory usage. This document describes how to manage Linux memory. For example, why is the memory used in Linux so high that free 1 GB of memory is only 232 MB? Windows xp only uses MB of memory. The following shows that free is the current memory usage. -M indicates M bytes to display the content. Let's take a look.

$ Free-m
Total used free shared buffers cached
Mem: 1002 769 232 0 62 421
-/+ Buffers/cache: 286 715
Swap: 1153 0 1153

Part 1 Mem row:
Total memory: 1002 MB
Used memory used: 769 MB
Free idle memory: 232 MB
Shared is no longer used. It is always 0.
Buffers Buffer cache memory: 62 MB
Cached Page cache memory: 421 MB

Link: total (1002 M) = used (769 M) + free (232 M)

Part 2 (-/+ buffers/cache ):
(-Buffers/cache) used memory size: 286 MB (refers to used-buffers-cached in the first part of the Mem row)
(+ Buffers/cache) free memory: 715 MB (refers to the first part of the Mem row free + buffers + cached)

It can be seen that-buffers/cache reflects the memory actually eaten by the program, while + buffers/cache reflects the total number of memories that can be used.

The third part refers to swap partitions. I don't want to understand it.

I think you are still dizzy after reading the above. The first part (Mem) and the second part (-/+ buffers/cache) are so strange about used and free.
In fact, we can explain it in two ways.
For the operating system, it is the Mem parameter. buffers/cached are all used, so it is considered that free is only 232.
For applications (-/+ buffers/cach ). buffers/cached is equivalent to available, because buffer/cached is used to improve the performance of program execution. When the program uses memory, buffer/cached will be quickly used.

So let's take a look at the application. The free and used of (-/+ buffers/cache) are the main ones. so let's just look at this. in addition, I would like to tell you some common sense. in order to improve disk and memory access efficiency, Linux has made a lot of elaborate designs, in addition to caching dentry (for VFS, accelerating file path name conversion to inode ), two major Cache methods are also adopted: Buffer Cache and Page Cache. The former is used to read and write disk blocks, and the latter is used to read and write inode files. These caches can effectively shorten the time for I/O system calls (such as read, write, getdents.

Remember that the memory is used, not for reference. Unlike windows, no matter how much physical memory you have, you need to read it from the hard disk swap file. This is why windows often prompts that virtual space is insufficient. You may think about it. When there is a large amount of memory, you can use some hard disk space to act as the memory. The hard disk is faster than the memory, so in Linux, as long as we don't need swap space for swap, we don't have to worry about having too little memory. If swap is often used, you may need to consider adding physical memory. This is also the Standard for Linux to check whether the memory is sufficient.

The Linux memory management method described in this article is helpful for you to learn about Linux.

  1. Allows you to use the Linux operating system to accelerate remote logon.
  2. Easily solve grub errors in Linux
  3. A Brief Introduction to Linux rescue
  4. Load average Load in Linux
  5. Slab allocator in Linux

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.