Memory Management for Linux

Source: Internet
Author: User

Http://www.linuxeye.com/Linux/1932.html

Memory Management for Linux

The memory of Linux is divided into: physical memory and virtual memory.
Physical memory is the amount of memory provided by the system hardware and is real memory.
Virtual Memory: Virtual memory is a strategy to meet the lack of physical memory, it is the use of disk space virtual out of a piece of logical memory, the disk space used as virtual memory is called swap space (swap spaces).
Usage scenario: Insufficient physical memory, the Linux kernel writes the temporarily unused memory data to the swap space, the physical memory is freed, and when the data is needed, the physical memory is read from the swap space.

Common memory monitoring commands: Top free
Free

Total: Overall physical memory size
Used: The amount of physical memory already in use
Free: idle physical memory size
Shared: The amount of memory that multiple processes share
buffers/cached: Size of the disk cache

Men: Representing physical memory usage
Buffers/cache: Represents disk Cache usage
Swap: Represents the use of swap space.

Look at the state of the memory from the kernel point of view:
Physical memory size 7820M, free memory size 824M. The memory already used is 7820-824=6996m. Available memory 824 does not contain buffers and cached.
The kernel takes full control of the memory usage, and Linux changes the buffers and cached state of memory into free memory for system use when memory is needed, or when the system is running incrementally.

Look at the state of the memory from the application layer's perspective:
Already using 4093M, the available space size is 3727M. 3727=190+2712+824
The physical memory value available to the application is the sum of the free values of the mem items plus the buffers and cached values, that is, the free value is the size of the buffers and cached items, and for the application, the buffers/cached occupied memory is available, Because buffers/cached is designed to improve the performance of file reads, buffers/cached is quickly recycled for application use when the application needs memory.

To reduce the time and resource consumption of disk read data, Linux introduces the buffer/cache mechanism
Buffers and cached are memory operations that are used to save files and file attribute information that have been opened by the system, so that when the operating system needs to read some files, it will first look in the buffers and cached memory areas, and if found, read them directly to the application. If you do not find the data needed to read from disk, this is the operating system caching mechanism, through the cache, greatly improve the performance of the operating system. But the content of buffers and cached buffers is different.

Buffers is mainly used to store content in the directory, file attributes and permissions, and so on. and cached is used directly to memorize the files and programs we have opened.

Memory Management for 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.