How to view system memory usage in linux

Source: Internet
Author: User


In Windows, it is very easy to view the memory usage. I think everyone is familiar with it. How can I check the memory usage in linux?

The following is a free command to view memory usage in Linux: [root @ scs-2 tmp] # free total used free shared buffers cached Mem: 3266180 3250004 16176 0 110652-/+ buffers/cache: 2668236 471116 www.2cto.com Swap: 2795064 2048276 80160 the following is an explanation of these values: 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. 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 is used, so its available memory is 16176KB, the memory used is kb, including the + buffers + cached used by the kernel (OS) + Application (X, oracle, etc. 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. Www.2cto.com 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 www.2cto.com LowTotal: 3266180 kB LowFree: 17456 kB SwapTotal: 2048276 kB SwapFree: 1968116 kB Dirty: 8 kB Writeback: 0 kB Mapped: 345360 kB Slab: 112344 kB Comm Itted_AS: 535292 kB PageTables: 2340 kB VmallocTotal: 536870911 kB VmallocUsed: 272696 kB VmallocChunk: 536598175 kB HugePages_Total: 0 HugePages_Free: 0 Hugepagesize: 2048 kB. Results: [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 www.2cto.com view/proc/kcore file size (memory image): [root @ scs-2 tmp] # ll-h/proc/ Kcore-r --- 1 root 4.1G Jun 12/proc/kcore remarks: memory usage measurement measures the memory occupied by a process, linux provides us with a very convenient method. The/proc Directory provides us with all the information. In fact, top and other tools also use this to obtain the relevant information. The memory usage information of the/proc/meminfo machine/proc/pid/maps pid indicates the process number and displays the virtual address occupied by the current process. /Proc/pid/memory occupied by the statm process [root @ localhost ~] # Cat/proc/self/statm 654 57 44 0 0 334 0 www.2cto.com output explanation CPU and CPU0... The meaning of each parameter in each row (in the first behavior example) is: Parameter Interpretation/proc // status Size (pages) task virtual address space Size VmSize/4 Resident (pages) the physical memory size that the application is using. VmRSS/4 Shared (pages) Shared pages 0 Trs (pages) the executable virtual memory size of the program VmExe/4 Lrs (pages) size of the library 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 www.2cto.com total used free shared buffers cached Mem: 1023788 926400 97388 0 134668 503688-/+ buffers/c Ache: 288044 735744 Swap: 1959920 89608 1870312 when we run the free command to check the idle memory of the machine, we will find that the value of free 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 author wayne173

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.