1. The connection and introduction of the SWAP area and / TMP folder.
The role of SWAP space can be described as: When the physical memory of the system is not enough, it is necessary to release some of the space in the physical memory to be used for currently running. Those spaces that are released may come from some of the programs that have nothing to operate. These released spaces are temporarily saved to the SWAP space, waiting until those program runtime, resume saved data from SWAP to memory. In this way, the system always performs SWAP exchange when physical memory is not enough. This phenomenon is often encountered for computer users. One point to declare is that all data exchanged from physical memory will be placed in swap (if such, SWAP will be overwhelmed), and there is a considerable part of the data directly to the file system. For example, some procedures open some files, read and write files (in fact, each program opens at least one file, that is, running the program itself), when the memory space of these programs need to be exchanged, the file part data is not It is necessary to put it in the SWAP space. If it is a read file operation, then the memory data is released directly, and it is not necessary to exchange it. Due to the next time, it can restore directly from the file system; if it is written, only needs The changed data is saved to the file in order to recover. But those use malloc
3C
) The data of the object generated by the NEW function (the statement allocated in the C language) is different, requiring SWAP space because they have no corresponding "reserve" file in the file system, so it is called "anonymous) Memory data, such data also includes some status and variable data in the stack, so SWAP space is the "anonymous" data exchange space. For example, the web server can derive multiple service processes (or threads) depending on the number of requests. If the SWAP space is run, the service process cannot be able to progress, and the "Application IS Out of Memory" is usually appeared, and it will be severe. Causes the deadlock of the service process. Normally, the SWAP space should be greater than or equal to the size of physical memory, minimum should not be less than
64M
Usually the size of the SWAP space should be 2-2.5 times the physical memory (the version above Solaris 2 changes, see below). However, according to different applications, there should be different configurations: if it is a small desktop system, only smaller SWAP spaces, while large server systems require different SWAP spaces. In particular, the database server and the web server will increase with the amount of access, and the requirements for SWAP space will also increase, and the specific configuration see the description of the respective server products. In addition, the number of SWAP partitions has a great impact on performance. Because the operation of the SWAP exchange is the operation of disk I / O, if there is a plurality of SWAP switches, the allocation of the SWAP space will operate in all SWAP in a turning manner, which will greatly balance the I / O load, speed SWAP exchange speed. If there is only one switching area, all exchange operations make the exchange area very busy, so that the system is waiting for the waiting state, the efficiency is very low, and the performance monitoring tool will find that the CPU is not very busy. The system is slow, this shows that the bottleneck is on I / O, and the speed of improving the CPU is not problematic. Performance Monitoring is the most commonly used VMSTAT command, with this command under most UNIX platforms, this command can view most of the performance indicators. Also use SWAP -S to see the current SWAP resource usage. For example: # swap -s Do you know? Virtual SWAP space has a considerable relationship with the / TMP directory. When Sun is implemented / TMP catalog, it fully considers the efficiency of the application operation. Many applications, especially database services, frequently using the / TMP directory as a temporary data save area, and Solaris puts the files in the / tmp instead of the hard disk, which greatly improves the efficiency of the application. However, the space of the / TMP directory is squeezed from the system virtual space and is part of the virtual SWAP space. If you have finished using the / TMP space, it is used to use the SWAP space, so you have to monitor the usage of the system / TMP directory, don't use the light, otherwise the system will be paralyzed! Below two suggestions as a reference: 1. When using the (-O size) option, use the (-O size) option to control the size of the / tmp directory. 2. When using a compiler to compile file, if you do not want to take up SWAP space, use the TMPDIR environment variable to point to another temporary directory, not / tmp directory. Increase SWAP Space 1. Be superuser $ su - root 2. Create a swap file #mkfile nnn [klblm] filename such as: # mkfile100m