View free memory usage

Source: Internet
Author: User

Free:

Total used free shared buffers cached
Mem: 8086108 6252924 1833184 0 213844 5116656
-/+ Buffers/cache: 922424 7163684
Swap: 15623204 68 15623136

The second line is from the OS perspective. Buffer and cached are both used by the system, but this part of memory can be applied.ProgramTo use it immediately.

Cached is a cache. It saves the read data. If you find the required data, do not read it from the hard disk. If you do not find the desired data, do not read it from the hard disk.

Buffers is a buffer. Based on the disk's read/write design, buffers perform distributed write operations in a centralized manner, reducing disk fragments and repeated seek paths on the hard disk, thus improving system performance.

The third line is from the perspective of the program, the used memory and idle memory, 7163684 = 1833184 + 213844 + 5116656, and its free = the sum of the three in the previous line.

Swap: 15623204 68 15623136: swap memory. The more swap memory is used, the more hard disk and memory is used by the program.

===========================================================

From: http://blog.chinaunix.net/space.php? Uid = 20551291 & Do = Blog & cuid = 2526856

ViewMemoryThe usage is very simple. I think everyone is familiar with it. How can I check the memory usage in Linux? The following is a free command for checking memory usage in Linux:

[Root @ scs-2 TMP] # Free

Total used free shared buffers cached

Mem: 3266180 3250004 16176 0 110652 2668236

-/+ Buffers/cache: 471116 2795064

Swap: 2048276 80160 1968116

The following is an explanation of these values:

Total: total physical memory size.

Used: used.

Free: available.

Shared: The total memory shared by multiple processes.

Buffers/cached: disk cache size.

Row 3 (-/+ buffers/cached ):

Used: used.

Free: available.

The fourth line won't be explained much.

Difference: used/free of the second row (MEM) differs from used/free of the third row (-/+ buffers/cache.
The difference between the two is that from the perspective of usage, the first line is from the OS perspective, because for OS, buffers/cached
They are all used, so the available memory is 16176kb and the used memory is 3250004kb, including kernel (OS) usage + application (X,
+ Buffers + cached.

The third line indicates that, from the application perspective, for applications, buffers/cached is equivalent to available, because buffer/cached is designed to improve file read performance, when the application needs to use the memory, buffer/cached will be quickly recycled.

From the application perspective, the available memory = system free memory + buffers + cached.

For example:

2795064 = 16176 + 110652 + 2668236

Next, we will explain when the memory will be exchanged and by which side. When the available memory is less than the rated value, a meeting will be held for exchange.

Rating:

CAT/proc/meminfo

[Root @ scs-2 TMP] # Cat/proc/meminfo

Memtotal: 3266180 KB

Memfree: 17456 KB

Buffers': 111328 KB

Cached: 2664024 KB

Swapcached: 0 KB

Active: 467236 KB

Inactive: 2644928 KB

Hightotal: 0 KB

Highfree: 0 KB

Lowtotal: 3266180 KB

Lowfree: 17456 KB

Swaptotal: 2048276 KB

Swapfree: 1968116 KB

Dirty: 8 KB

Writeback: 0 KB

Mapped: 345360 KB

Slab: 112344 KB

Committed_as: 535292 KB

Pagetables: 2340 KB

Vmalloctotal: 536870911 KB

Vmallocused: 272696 KB

Vmallocchunk: 536598175 KB

Hugepages_total: 0

Hugepages_free: 0

Hugepagesize: 2048 KB

View the result in free-M:

[Root @ scs-2 TMP] # Free-m

Total used free shared buffers cached

Mem: 3189 3173 16 0 107 2605

-/+ Buffers/cache: 460 2729

Swap: 2000 78 1921

View the size of the/proc/kcore file (memory image ):

[Root @ scs-2 TMP] # ll-H/proc/kcore

-R --- 1 Root 4.1g Jun 12 12:04/proc/kcore

Note:

Memory usage Measurement

Measure how much memory a process occupies. Linux provides us with a very convenient method. The/proc Directory provides us with all the information, in fact, the top tool also obtains the corresponding information here.

/Proc/meminfo memory usage information of the machine

/Proc/Pid/maps PID is the process number and displays the virtual address occupied by the current process.

Memory occupied by/proc/Pid/statm Process

[Root @ localhost ~] # Cat/proc/self/statm

654 57 44 0 0 334 0

Output description

CPUAnd cpu0... The meaning of each parameter in each row (in the first behavior example) is:

Parameter description/proc // status

Size (pages) task virtual address space size vmsize/4

The size of the physical memory that the resident (pages) application is using vmrss/4

Shared (pages) shared pages 0

Size of executable virtual memory owned by the TRS (pages) program vmexe/4

The size of the library that the LRS (pages) is mapped to the virtual memory space of the task. vmlib/4

Drs (pages) Program Data Segment and user-state stack size (vmdata + vmstk) 4

DT (pages) 04

View available machine memory

/Proc/28248/> free

Total used free shared buffers cached

Mem: 1023788 926400 97388 0 134668 503688

-/+ Buffers/cache: 288044 735744

Swap: 1959920 89608 1870312

When we run the free command to view the idle memory of the machine, we will find that the free value is very small. This is mainly because there is such an idea in Linux, the memory does not need to be white, so it tries its best to cache and buffer some data for the next use. But in fact, these memories can also be used immediately.

So free memory = free + buffers + cached = total-used

$ 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:286 m(Used-Buffers-cached in the first part of the mem row)
(+ Buffers/cache) free memory:715 m(Free + buffers + cached in the first part of the mem row)

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. (From here we can see that,Actually: available memory = free + buffers + cached in the first part of MEM, not only free)

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, with (-/+
The free and used of buffers/cache are the main ones. So let's take a look at this. In addition, I would like to tell you some common sense. In order to improve the disk and memory access efficiency of Linux,
Linux has made a lot of elaborate designs, except for caching dentry (for VFS, to accelerate the conversion from file path name 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 when the I/O system calls (such as read, write, getdents.

Remember that the memory is used for usage, not for reference. Unlike windows, no matter how much physical memory you have, it will take hard disk swap files to read. This is why Windows is often used.
The cause of insufficient virtual space is often prompted. think about it. It's boring. When there is still a large amount of memory, you can use some hard disk space to act as the memory. how is the hard disk faster than the memory. so if we look at Linux
Without swap space, you don't have to worry that your memory is too small. If swap often uses a lot, you may have to consider adding physical memory. This is also the Standard for Linux to check whether the memory is sufficient.

Supplement: CAT/proc/meminfo

You can view the memory usage details. The free result is generated by this file.

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.