First, what is called the swap partition
The role of swap partitions, or swap spaces, can be simply described as: when the physical memory of the system is not enough, it is necessary to release some of the space in physical memory for use by the currently running program. The freed space may come from programs that have not been manipulated for a long time, and the freed space is temporarily saved in the swap space until those programs run, recovering the saved data from the swap into memory.
Second, the swap configuration on the performance of the impact
Swap adjustments are critical to the performance of Linux servers, especially Web servers. By adjusting swap, you can sometimes bypass system performance bottlenecks and save on system upgrade costs. But allocating too much swap space wastes disk space, and there is too little swap space for the system to get an error.
If the system is running out of physical memory, the system will run slowly, but still be able to run, and if the swap space is exhausted, the system will have an error. For example, a Web server can derive multiple service processes (or threads) depending on the number of requests, if the system has insufficient physical memory, the Web site will be slow to open, the ping may drop packets, the delay is large, and if the swap space is exhausted, the service process will not start, and typically "application is Out of memory "error, serious when the service process is causing a deadlock. Therefore, the allocation of swap space is very important.
Iii. partitioning rules for swap partitions
In Linux, we have some rules on the partitioning of the swap partition, when the physical memory is less than 2G, the size of the swap partition is twice times the physical memory, and more than 2G, the swap partition size is equal to the physical memory.
The formula is as follows: X represents physical memory, y represents the swap partition
When x<2g, y=2x;
When 2g<x<32g, y=4+ (x-2);
When x>=32g,,y<=x;
Example: When the physical memory is 4G, swap is 6G, and when the physical memory is greater than 32G, the swap partition is less than or equal to the physical memory.
Four, the memory view
1, Free-m
-M already in megabytes view
2, Swapon-s
View the status of the swap, the size of the used and unused resources.
3. Top
Dynamic viewing, but resource consumption is large when using the top command
Top-p PID View Resource usage for a process
Other: P: Rank by%CPU usage rate
T: Rank by mite+
M: Ranked by%mem
4. Pamp View the memory image information of the process
pmap-d PID
[[email protected]/]# pmap-d 1 | Tail
00b7c000 4 rw---0000000000024000 0fd:00000 init
00efc000 4 r-x--0000000000000000 000:00000 [anon]
00f54000 r-x--0000000000000000 0fd:00000 libnih-dbus.so.1.0.0
00f5d000 4 R----0000000000008000 0fd:00000 libnih-dbus.so.1.0.0
00f5e000 4 rw---0000000000009000 0fd:00000 libnih-dbus.so.1.0.0
01abd000 RW---0000000000000000 000:00000 [anon]
b76fe000 RW---0000000000000000 000:00000 [anon]
b770f000 4 rw---0000000000000000 000:00000 [anon]
bfb59000-RW---0000000000000000 000:00000 [stack]
mapped:2896k writeable/private:292k shared:0k
The value of the last row, mapped represents the size of the virtual address space of the process map, that is, the process pre-allocated virtual memory size, that is, PS out of the vsz;writeable/private represents the size of the private address space occupied by the process, that is, the process of the actual use of memory size;
GKFX represents the amount of memory shared by the process and other processes.
This article is from the "Jx_ Trench linux" blog, so be sure to keep this source http://xujunxian.blog.51cto.com/8614409/1542985