When we use the Linux memory free command to view the machine's idle memory, we will find that the value of free is very small. Next, let's take a look at the Linux memory viewing commands and explanations for these commands, so that you can have a deeper understanding of our Linux memory viewing commands.
To view the memory in Linux, we generally use the free command:
[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 in the Linux memory command:
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 is used, so its available memory is 16176KB, memory in use is kb, including kernel OS + + Application (X, oracle, etc) + 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.
In Linux, how does one view the rating when viewing memory commands:
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 memory image of the/proc/kcore file ):
[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
Linux memory command output explanation
CPU and CPU 0... For each parameter in each row of, the first behavior is used as an example:
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 \
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
- Detailed introduction to linux performance monitoring
- Development and Application of linux Network Monitoring System
- How to share Linux traffic monitoring
- System Monitoring: linux System Monitoring command details
- Linux memory monitoring process details