It's easy to see how memory is being used in a Windows system, and presumably everyone is familiar with it, so how do you see memory usage in a Linux system? Below you will find the free command to view memory usage under Linux systems:
- [[email protected] tmp]# free
- Total used free shared buffers cached
- mem:3266180 3250004 16176 0 110652 2668236
- -/+ buffers/cache:471116 2795064
- swap:2048276 80160 1968116
Here is an explanation of these values:
Total: The amount of physical memory.
Used: How large is used.
Free: How much is available.
Shared: The total amount of memory shared by multiple processes.
Buffers/cached: The size of the disk cache.
Third line (-/+ buffers/cached):
Used: How large is used.
Free: How much is available.
There is not much to explain in line four.
Difference: The used/free of the second line (MEM) differs from the third row (-/+ Buffers/cache) used/free. The difference between the two is that the first line is from the OS point of view, because for the os,buffers/cached are all belong to be used, so his available memory is 16176KB, the used memory is 3250004KB, which includes, the kernel (OS) uses + Application (X, ORACLE,ETC) uses the +buffers+cached.
The third line refers to the application from the point of view, buffers/cached is equal to the availability of the application, because buffer/cached is to improve the performance of the file read, when the application needs to use memory, buffer/cached will be quickly recycled.
So from the application's point of view, available memory = System Free memory+buffers+cached.
As in the above example:
2795064=16176+110652+2668236
Next, explain when the memory will be exchanged, and by what side. When the available memory is less than the rated value, a meeting is exchanged.
How to see the rating:
- Cat/proc/meminfo
- [email protected] 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
Results viewed with free-m:
- [email protected] tmp]# free-m
- Total used free shared buffers cached
- mem:3189 3173 0 107 2605
- -/+ buffers/cache:460 2729
- swap:2000 1921
To view the size of the/proc/kcore file (memory image):
- [email protected] tmp]# ll-h/proc/kcore
- -r--–1 root root 4.1G June 12:04/proc/kcore
remark: memory-intensive measurements
Measuring how much memory a process consumes, the Linux system provides a convenient way for us to provide all the information that the/proc directory provides, in fact top tools are also available here to obtain the appropriate information.
- memory usage information for/proc/meminfo machines
- The /proc/pid/maps PID is the process number that displays the virtual address occupied by the current process.
- memory occupied by the/PROC/PID/STATM process
- [email protected] ~]# CAT/PROC/SELF/STATM
- 654 0 0 334 0
Output interpretation
CPU and CPU0 ... The meaning of each parameter of each row (in the first example) is:
Parameter Interpretation/proc//status
Size (pages) task virtual address space VMSIZE/4
Resident (pages) the size of the physical memory that the application is using VMRSS/4
Shared (pages) pages 0
The size of the executable virtual memory owned by the TRS (pages) program VMEXE/4
The size of the library in which Lrs (pages) is imaged into 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 Machine available 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 look at the idle memory of the machine with the free command, we find that the value of the. This is mainly because, in the Linux system there is such a thought, the memory is not white, so it as far as possible cache and buffer some data to facilitate the next use. But in fact, the memory is also available for immediate use.
So free memory =free+buffers+cached=total-used
Explanation of the free command