Linux to view memory commands and their interpretation of the command display

  

We look at the memory free command through Linux to see the free memory of the machine, you will find that the value of free is very small. Let's take a look at the commands for viewing Linux memory and the explanation of these commands, so that we can better understand our Linux view memory commands.

Viewing memory under Linux We usually use the free command: [root @ scs-2 tmp] # freetotal used free shared buffers cachedMem: 3266180 3250004 16176 0 110652 2668236 - /+ buffers /cache: 471116 2795064Swap: 2048276 80160 1968116

the following is a view of the memory command values ​​for these Linux Explanation: total: Total physical memory size. Used: How old has been used. Free: How much is available. Shared: The total amount of memory shared by multiple processes. Buffers/cached: The size of the disk cache. The third line (-/+ buffers/cached): used: how old it is. Free: How much is available. The fourth line will not explain much. The difference: the difference between the used/free of the second line (mem) and the used/free of the third line (-/+ buffers/cache). The difference between the two is that from the perspective of use, the first line is from the perspective of the OS, because for the OS, buffers/cached are used, so his available memory is 16176KB, and the used memory is 3250004KB. This includes the kernel (OS) using +Application(X, oracle, etc) using +buffers+cached. The third line refers to the application. For applications, buffers/cached is equal to available. Because buffer/cached is to improve the performance of file reading, when the application needs to use the memory, the buffer/cached will be quickly recycled. So from the application point of view, available memory = system free memory + buffers + cached. The above example: 2795064=16176+110652+2668236

The next step is to explain when the memory will be exchanged and by what side. When the available memory is less than the rated value, it will meet for exchange. Linux how to look at ratings when viewing the memory command: cat /proc /meminfo [root @ scs-2 tmp] # cat /proc /meminfoMemTotal: 3266180 kBMemFree: 17456 kBBuffers: 111328 kBCached: 2664024 kBSwapCached: 0 kBActive: 467236 kBInactive: 2644928 kBHighTotal : 0 kBHighFree: 0 kBLowTotal: 3266180 kBLowFree: 17456 kBSwapTotal: 2048276 kBSwapFree: 1968116 kBDirty: 8 kBWriteback: 0 kBMapped: 345360 kBSlab: 112344 kBCommitted_AS: 535292 kBPageTables: 2340 kBVmallocTotal: 536870911 kBVmallocUsed: 272696 kBVmallocChunk: 536598175 kBHugePages_Total: 0HugePages_Free: 0Hugepagesize: 2048 kB

the results with free -m see: [root @ scs-2 tmp] # free -m total used free shared buffers cachedMem: 3189 3173 16 0 107 2605 - /+ buffers /cache: 460 2729Swap : 2000 78 1921

View the size of the /proc/kcore file (memory mirror): [root@scs-2 tmp]# ll -h /proc/kcore -r-------- 1 Root root 4.1G Jun 12 12:04 /proc/kcore

Note: The measurement of memory usage measures how much memory a process occupies. Linux provides us with a convenient Method, /proc directory provides us with all the information, in fact, top and other tools to get the appropriate information here. /proc/meminfo The machine's memory usage information /proc/pid/maps pid is the process number, which shows the virtual address occupied by the current process. /Proc /pid /statm process memory occupied [root @ localhost ~] # cat /proc /self /statm654 57 44 0 0 334 0

Linux command to view memory and CPU Output Interpreter CPU0. . . The meaning of each parameter of each line (in the first behavior example) is:

Parameter interpretation /proc//statusSize (pages) The size of the task virtual address space VmSize/4Resident(pages) The application is using The size of the physical memory VmRSS/4Shared(pages) Shared Pages\\Trs(pages) The size of the executable virtual memory owned by the program VmExe/4Lrs(pages) The size of the library that is mapped to the virtual memory space of the task VmLib/4Drs( Pages) Program data segment and user mode stack size (VmData+ VmStk)4

dt(pages) 04

View machine available memory/proc/28248/>freetotal used free shared buffers cachedMem: 1023788 926400 97388 0 134668 503688 - /+ buffers /cache: 288044 735744Swap: 1959920 89608 1870312

we view the free memory machine by free command, you will find the value of a small free. This is mainly because, in Linux, there is such an idea that memory does not need to be used, so it should cache and buffer some data as much as possible to facilitate the next use. But in fact, these memories can be used immediately.

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

Copyright © Windows knowledge All Rights Reserved