free-simple and clear explanation how to see memory usage

Source: Internet
Author: User

The free command can be used to view system memory usage. I am generally accustomed to the-m parameter view in megabytes

[Email protected] ~]# free-m       total used free     shared    buffers     cachedmem:        1020288     947960      72328        312      82656     647740-/+ buffers/cache:     217564     802724Swap:        2097148     466656    1630492

Other parameters

    • -B Displays memory usage in bytes.
    • -K displays memory usage in kilobytes.
    • -m displays memory usage in megabytes.
    • -G displays memory usage in gigabytes.
    • -O does not display buffer throttling columns.
    • -s< interval seconds > Continuous observation of memory usage.
    • -T displays the memory sum column.
    • -V Displays version information.

Explain:

  • Total: Is the overall physical memory
  • Used: in-use memory
  • Free: Completely idle memory
  • Shared: Memory for multiple processes
  • Buffers: Write cache, before writing to disk, the data is cached for a period of time, you can release
  • Cache: Read cache, read files, will be cached for a period of time. Can release
  • -buffers/cache: Memory size In actual use of the application, equal to Used-buffers-cached(three number of mem columns)
  • +buffers/cache: Total amount of memory available, equal to free+buffers+cached(three number of mem columns)
  • Swap: No explanation, you can read it.

So, the memory that can be used by the program should look +buffers/cache (), not free.

How can you say that there is enough memory to use the swap?

As I understand it, the system allocates memory, if found out of memory, will release a batch of old cache, the space for the new application process, and sometimes release is not sufficient or not timely, so began to use the swap!

Manually releasing the cache

Use the Sync command to force the buffer to the hard disk, sometimes fearing that the configuration will not take effect and use it to force write to the hard disk. If the system suddenly loses power, buffer data is not saved, it will be lost! In fact, in most cases, memory is consumed by the cache, not buffer!

Here's how to use Sysctl to force the release of the cache, and the kernel parameters associated with the memory release are vm.drop_caches,vm.drop_caches can be set to 0, 1, 2, 3.

Description

0 default value before action is taken

1 release Pagecache

2 Releasing Dentries and Inodes

3 releasing Pagecache, Dentries and Inodes

The actual operation can use the following sysctl, also can use echo 3 >/proc/sys/vm/drop_caches, the same effect!

[Email protected] ~]# sysctl vm.drop_caches=3vm.drop_caches=3[[Email protected]~]# free-m total used free shared buffers Cachedmem:996          the        907          0          0          A-/+ Buffers/cache: the        920Swap:2047        455       1592

But this will slowly rise up!

Reference: HTTP://BLOGREAD.CN/IT/ARTICLE/7195?F=WB

free-simple and clear explanation how to see memory usage

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.