Linux query memory real utilization

  

Use the top tool to view the memory usage of Suse Linux is very large, probably 97% or more, I know this is the memory usage mechanism of Linux, first manage the memory, when needed Assigned to a single process. But what if I need to check the real memory usage of the system?

The following shows that free is the display of the current memory usage, -m means M bytes to display the content. Let's take a look.< Br>

$ free -m total < Wbr> used free shared buffers cachedMem: 1002 < Wbr> 769 232 < Wbr> 0 62 < Wbr> 421-/+ buffers/cache: 286 715Swap: 1153 0 1153

---------------------------------------Real memory usage = used-buffers-cached = 286---------------------------------------

The first part of Mem line: total Total memory: 1002Mused The number of used memory: 769Mfree Idle memory: 232Mshared Currently obsolete, always 0buffers Buffer Cache memory: 62Mcached Page Cache memory: 421M

Relationship: total(1002M) = used(769M) + free(232M)

Second part (-/+ buffers/cache): (-buffers/cache) used memory: 286M (refers to The first part of the Mem line is used - buffers - cached) (+buffers /cache) free memory: 715M (refers to the first part of the Mem line free + buffers + cached)

visible -buffers /cache reflection The memory that is actually eaten by the program, and +buffers/cache reflects the total amount of memory that can be used.

The third part refers to the swap partition, I don't want everyone to understand.

I think everyone looked at it, it is still dizzy. The first part (Mem) and the second part (- /+ buffers/cache) The reason why used and free are so strange. In fact, we can explain from two aspects. For the operating system
, it is the parameter of Mem. Buffers/cached belongs to the Use, so it thinks free is only 232. For the application it is (-/+ buffers/cach).buffers/cached is equivalent, because buffer/cached is to improve the performance of program execution, when the program uses memory, Buffer/cached will be used very quickly.

So, take a look at the application, with (-/+ buffers/cache) free and used. So we can see this. Also tell everyone some common sense. Linux to improve disk and memory Access efficiency, Linux has done a lot of careful design, in addition to caching dentry (for VFS, speed up file path name to inode conversion), also adopted two main Cache methods: Buffer Cache and Page Cache. The former is for reading and writing of disk blocks, and the latter is for reading and writing of file inodes. These Caches can effectively reduce the time of I/O system calls (such as read, write, getdents).

Remember that memory is used, not to look at it. Unlike windows, no matter how much real physical memory you have, he has to read the hard disk to exchange files. This is why windows often Prompt the reason for the lack of virtual space. Think about it, how boring, when there is most of the memory, take out some of the hard disk space to act as memory. How can the hard disk pass faster than memory? So we look at Linux, as long as there is no swap space for swap Don't worry about your own memory is too small. If you often use a lot of swap, you may want to consider adding physical memory. This is also the standard for Linux to see if the memory is sufficient.

Copyright © Windows knowledge All Rights Reserved