Ubuntu who is using swap




















When this happens, inactive pages from the physical memory are then moved into the swap space, freeing up that physical memory for other uses. Note that the access time for swap is slower, depending on the speed of the hard drive. Do not consider it to be a complete replacement for the physical memory. Swap space can be a dedicated swap partition recommended , a swap file, or a combination of swap partitions and swap file s. Memory consuming programs Sometimes, a large program like LibreOffice , Neverwinter Nights, or a video editor make the entire system need extra memory.

A significant number of the pages used by these large programs during its startup may only be used for initialization and then never used again. The system can swap out those pages and free the memory for other programs or even for the disk cache. In these cases, swap will be used to help the system handle any extra load.

Hibernation suspend-to-disk The hibernation feature suspend-to-disk writes out the contents of RAM to the swap partition before turning off the machine. Therefore, your swap partition should be at least as big as your RAM size. Although the latest versions of Ubuntu don't support hibernation OOTB you may configure your system to allow Hibernation. Unforeseeable Circumstances Unforeseeable events can and will happen a program going crazy, some action needing much more space than you thought, or any other unpredictable combination of events.

In these cases, swap can give you an extra delay to figure out what happened, or to finish what you are working on. Optimizing memory usage Since mechanical hard drives are considerably slower than RAM SSD - Solid State Drive - storage is not as slow as physical drives, but still slower than RAM , when you need a file be it a data file like a video, executables like Firefox, or libraries , the Linux kernel reads the file into RAM and keeps it there, so that the next time you need it, it is already in RAM and data access is much faster.

The portions of RAM that accelerate disk read are called "cached memory. The Linux kernel automatically moves RAM reserved by programs--but not really used--into swap, so that it can serve the better purpose of extending cached memory. Optimizing Swap performance Because swap space uses a disk device, this can cause performance issues in any system that uses swap space significantly because the system itself may also be using the same disk device at the same time that it is required for swap operations.

One way to reduce this problem is to have swap space on a different physical drive so that the competition for that resource is either reduced or eliminated. Also, it's recommended that the swap space is maximum twice the amount of RAM depending upon the amount of hard disk space available for the system because of diminishing returns.

The only downside to having more swap space than you will actually use, is the disk space you will be reserving for it.

Swap is generally associated with a swap partition, perhaps because the user is prompted to create a swap partition at the time of installation.

In fact, any file can be used as a swapping device, be it a partition or a conventional file. Swap can be added by increasing the size of the swap partition or by adding a swap file. Keep in mind that when creating a swap file that it may not necessarily be using contiguous disk blocks as a swap partition will , and this could have a negative impact on performance as disk access times may be longer, and the more your system uses swap, the worse it will be.

The Linux kernel also accesses swap disk block IO directly bypassing all caching, metadata and filesystem code, so a swap file should have no ill effect on the stability of your base filesystem.

Since kernel 2. The advantages of a swap file are many, but it is problematic for using the default swsusp hibernation method for powerless sleep. The best solution for maintaining hibernate capability after adding RAM is to increase the size of the swap partition.

Telling the system not to rely on the swap much will generally make your system faster. Values that are closer to will try to put more data into swap in an effort to keep more RAM space free. For a Desktop, a swappiness setting of 60 is not a bad value. For a server, you might want to move it closer to 0. This setting will persist until the next reboot. This setting configures how much the system will choose to cache inode and dentry information over other data.

Basically, this is access data about the filesystem. You can see the current value by querying the proc filesystem again:. As it is currently configured, our system removes inode information from the cache too quickly. We can set this to a more conservative setting like 50 by typing:.

Again, this is only valid for our current session. We can change that by adding it to our configuration file like we did with our swappiness setting:. Following the steps in this guide will give you some breathing room in cases that would otherwise lead to out-of-memory exceptions. Swap space can be incredibly useful in avoiding some of these common problems. If you are running into OOM out of memory errors, or if you find that your system is unable to use the applications you need, the best solution is to optimize your application configurations or upgrade your server.

What is Swap? Where would you like to share this to? Twitter Reddit Hacker News Facebook. Share link Tutorial share link. Sign Up. DigitalOcean home. Community Control Panel. You can just use a swap file rather than a partition. Home Contact. Posted by Meilin in General. Raj Kumar said, in December 30th, at am Thank you…followed instructions and made permanent change.

So far, so good.



0コメント