free memory monitor

Syntax: free [-bkmotV] [- s <spaced seconds>]

Supplement: free command displays memory usage, including physical memory, virtual memory swap files, shared memory segments, core and buffer systems used.

Participation number:

-b to Byte Displays memory usage.

-k in KB display memory usage.

-m in MB display memory usage.

-o not display buffer adjustment column.

-s <interval seconds> memory usage is continuously observed.

-t display memory column sums.

-V Display version information.

 

Mem: represents the physical memory statistics

- / + buffers / cached: represents the physical memory of the cache statistics

Swap: represents the usage of the swap partition on the hard disk

Line 1 Mem: total: represents the total amount of physical memory.

used: represents the total allocated to the cache (containing buffers and cache) the number of used, but may not actually part of the cache use.

free: unallocated memory.

shared: shared memory, the system will not be used generally, is not discussed here.

buffers: the number of buffers assigned by the system but not in use.

cached: the number of cache system allocated but not used. The difference between buffer and cache, see below. total = used + free line 2 - / + buffers / cached: used: the first row is used - the total amount of memory buffers-cached are actually used.

free: buffers and cache unused and unallocated memory sum, this is the actual system currently available memory. free 2 = buffers1 + cached1 + free2 second row free1 //, buffers1 as the first row

A buffer is something that has yet to be "written" to disk A cache is something that has been "read" from the disk and stored for later use Line 3: 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 the performance of, when the application needs to use the memory at the time, buffer / cached will be recovered quickly.

So from the perspective of the application, the available system memory = free memory + buffers + cached.

Next, explain when the memory will be exchanged, and in what way exchange.

When available memory is less than the rated value, the exchange will meet to see how ratings (RHEL4.0):

#cat /proc/meminfo

The exchange to reduce the number of physical pages in the system used in three ways:

1. Reduce the size of the buffer and the page cache,

2. System V type of memory page swapping out,

3. pages swapped out or discarded. (Application occupied memory pages, that is, the physical memory).

In fact, a small amount to the swap is not affecting the system performance.

Here is the difference between buffers and cached in:

refers to the block buffers used to make the device buffer size, he only file system metadata records and tracking in-flight pages.

cached files are used to make buffer.

That is to say: buffers are used to store, catalog what's inside content, permissions, and so on.

The cached memory directly to our open files, if you want to know he is not really into effect, you can try, has performed twice command #man X, you can clearly feel the opening play of the second speed much faster.

Experiment: on a machine do not have what applications will see more obvious. Remember experiments can only be done once, if you want to do, please change a file name.

#free

#man X

#free

#man X

#free

You can display the size of the buffers is successively compare free after.

Another experiment:

#free

#ls / dev

#free

You compare the size of two, of course, the buffers are increasing at any time, but you have too ls, then increase the speed becomes faster, this is the buffers / chached difference.

Because Linux memory as temporary files you do not use and data cache to improve system performance when you need the memory, the system will automatically release (unlike windows so even if you have a lot of free memory, he would look at disk access the pagefiles)

Use the free command

Value minus the value of the used buffer and cache memory of what you currently use ----- real terms is the operating system's parameters .buffers Mem / cached belong to be used, so it is considered free only 16,936.

The application is concerned (- / + buffers / cach) .buffers / cached equivalent available, because buffer / cached in order to improve the performance of a program executed when a program uses memory, buffer / cached will soon be used . So, take a look at the application to (- / + buffers / cache) of free and used mainly so we look at this like another tell you some common sense .Linux to improve disk and memory access efficiency, Linux do. a lot of careful design, in addition to the dentry cache (for VFS, accelerated file pathname to inode conversion), cache also taken two main ways: buffer cache and Page cache. The former disk blocks for reading and writing, which read and write file for the inode. These Cache can effectively reduce the I / O system calls (such as read, write, getdents) time. Remember that memory is brought to use, not to take look. Unlike windows, regardless of your actual physical memory how much he must take the hard disk swap file to read. That's why the windows are often insufficient to suggest the cause of the virtual space . you think about it, more boring, as well as most of the time in memory, hard disk space to act out a part of the memory. how the hard disk will be faster than memory. so we see linux, as long as no swap swap space, do not have to worry about their too little memory. If you often use a lot of swap, you should probably consider adding a physical memory, which is also linux to see if enough memory standard, oh.

[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:

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.

Differences: The second line (MEM) is used / free and the third row - the difference (/ + buffers / cache) used / free of. Both the angle difference is the use of view, the first line is 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, These include, + buffers + cached kernel (OS) using the + Application (X, 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

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

[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

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):

[root@scs-2 tmp]# ll -h /proc/kcore

-r-------- 1 root root 4.1G Jun 12 12:04 /proc/kcore

Remarks:

Memory for measurements

A process of measuring how much memory, 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

[root@localhost ~]# 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

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

Guess you like

Origin www.cnblogs.com/fanweisheng/p/11108986.html