In the server running, use FREE-M to view the server memory, often found free value is very small, some students will be very nervous, always want to take some measures, make free value looks higher, in the mind is a bit more cool. In fact, personally feel that this is a picture of the fast, there is no substantive use.
First, the public release memory method
1. First use Free-m to view remaining memory
Copy Code code as follows:
linux-8v2i:~ # Free-m
Total used free shared buffers Cached
mem:3952 2773 178 0 130 1097
-/+ buffers/cache:1545 2406
swap:2055 0 2055
2. Execute sync command
Using the Sync command to ensure the integrity of the file system, the Sync command runs the Sync subroutine, writes all the outstanding system buffers to disk, contains modified I-node, deferred block I/O, and read-write mapping files.
Copy Code code as follows:
3. Modify/proc/sys/vm/drop_caches
Copy Code code as follows:
Echo 3 >/proc/sys/vm/drop_caches
Description
1>. /proc is a virtual file system that we can use as a means of communicating with the kernel entity through its read and write operations. That is, you can make adjustments to the current kernel behavior by modifying the files in/proc. That is, we can free up memory by adjusting the/proc/sys/vm/drop_caches.
2>. The official notes on Drop_caches are as follows:
Copy Code code as follows:
Writing to this file causes the kernel to drop clean caches,dentries and inodes from memory, causing that memory to become Free.
To-free Pagecache, use echo 1 >/proc/sys/vm/drop_caches;
To free dentries and inodes, use echo 2 >/proc/sys/vm/drop_caches;
To free Pagecache, dentries and inodes, use Echo 3 >/proc/sys/vm/drop_caches.
Because this are a non-destructive operation and dirty objects are not freeable, the user should run sync a.
3>. The Linux kernel caches its most recently accessed file page in memory for a period of time, a file cache called Pagecache.
4. Use Free-m to view the remaining memory, as follows:
Copy Code code as follows:
linux-8v2i:~ # Free-m
Total used free shared buffers Cached
mem:3952 1773 2325 0 0 80
-/+ buffers/cache:1545 2406
swap:2055 0 2055
Second, Linux memory analysis
1. First analysis of Free-m view results
Copy Code code as follows:
linux-8v2i:~ # Free-m
Total used free shared buffers Cached
mem:3952 2773 178 0 130 1097
-/+ buffers/cache:1545 2406
swap:2055 0 2055
The meaning of each parameter:
total: Total physical memory
used: Memory is used
Free: Memory that is completely unused
shared: Application shared memory
buffers: Cache, mainly used in the directory, Inode value, etc.
Cached: Caching, for open files
-buffers/cache: The memory size used by the application, used minus the cached value
+buffers/cache: All memory sizes available to the application, free plus cached values
which:
total = used + Free
-buffers/cache=used-buffers-cached, this is the memory size that the application actually uses
+buffers/cache=free+buffers+cached, this is the server's true and available memory size
2. Linux memory allocation
as we all know, Linux servers in order to improve efficiency, will be in advance to request memory, even if these memory is not used in specific applications, Linux will request these memory in advance, Then use these memory to do caching, will just open the file system into the cache, so that the corresponding server free value will be more and less, buffers and cached will be more and more, so give everyone the appearance is less memory, we are nervous; in fact, we do not need to be nervous at all, When a Linux server discovers low memory, it automatically cleans up the cached area, frees up memory, and then continues to grow cache,free continue to decrease. Therefore, the manual way to reduce memory usage, in fact, is a picture of the quick, hehe.