Following in Linux, we used the top command to view the system processes, top can also display system memory. View the contents of our common Linux commands special tools are free.
Under Linux command to view the free memory Explanation:
View memory in Linux we generally use the free command:
$ 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 a memory free command interpreter to view the contents of the output:
- total: total physical memory size.
- used: how much has been used.
- free: how much is available.
- Shared: multiple processes to share memory total.
- Buffers / cached: size of the disk cache.
The third row (- / + buffers / cached):
- used: how much has been used.
- free: how much is available.
The fourth line is not much to explain.
- / + buffers / cache meaning differences:
Used second row (MEM) is / free third row (- / + buffers / cache) used / free distinction is that the angle of view used:
- The second row from the perspective of the OS, because for OS, buffers / cached belong to be used, the available memory is so he 16176KB, used memory is 3250004KB, including the kernel (OS) using the + Application (X , + buffers + cached oracle, etc) used.
- The third line is referred to from the application point of view, for applications, buffers / cached is equal to available, because buffer / cached file is read in order to improve performance when used in applications that need the memory time, buffer / cached will soon be recovered.
So from the perspective of the application, the available system memory = free memory + buffers + cached.
The above example:
- 2795064=16176+110652+2668236
How memory exchange
Next, explain when the memory will be exchanged, and in what way exchange. When available memory is less than the rated value, a meeting will be exchanged. How to watch Ratings:
cat /proc/meminfo
The output is:
$ 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
With free -m to see the 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
View the size of / proc / kcore files (memory mirroring):
$ ll -h /proc/kcore
-r-------- 1 root root 4.1G Jun 12 12:04 /proc/kcore
Remarks:
Memory-intensive measurement
measuring how much memory a process, linux provides us with a very convenient way, / proc directory provides us with all the information, in fact, top and other tools to get the appropriate information here.
- Memory usage / proc / meminfo machine information
- / Proc / pid / maps pid is the process number, to display the current process virtual address occupied.
- / Proc / pid / statm process of memory occupied
$ cat /proc/self/statm
654 57 44 0 0 334 0
Output Interpreter
CPU and CPU0. . . The meaning of each parameter of each line (first line as an example) as:
Parameter Description / proc / status
Size (pages) task virtual address space size VmSize / 4
Physical memory Resident (pages) the size of the application is using VmRSS / 4
Shared (pages) shared pages 0
Trs (pages) program owned by the executable virtual memory size VmExe / 4
Lrs (pages) library is mapped to the task of virtual memory space size VmLib / 4
Stack size Drs (pages) segment program data and user state (VmData + VmStk) 4
dt(pages) 04
View available memory machine
/proc/28248/>free
total used free shared buffers cached
Mem: 1023788 926400 97388 0 134668 503688
-/+ buffers/cache: 288044 735744
Swap: 1959920 89608 1870312
Linux view memory and memory usage Summary:
When we look at the machine free memory by free command, you will find little value free. This is mainly because there is such an idea in linux, memory, not white do not, so it is possible some of the data cache and buffer, to facilitate the next use. But in fact these memory also can be used to immediately use.
Therefore, the free memory = free + buffers + cached = total-used