Why swap is used in linux




















Chapter 5. Swap Space. Swap space in Linux is used when the amount of physical memory RAM is full. If the system needs more memory resources and the RAM is full, inactive pages in memory are moved to the swap space. While swap space can help machines with a small amount of RAM, it should not be considered a replacement for more RAM. Swap space is located on hard drives, which have a slower access time than physical memory. I ended up needing MB RAM minimum just to run the site without it crashing due to memory exhaustion.

Think mashups. A lot of that sort of thing would break if you can't "render" the web page into some graphical context. By the way, this web framework is essentially dead now, so there's no point name-and-shaming it. Best to just take the broader lesson to heart: yes, swap is still useful even if you have gigs of free RAM.

I think "Gilles" already mentioned the fact that, while you may have more than enough RAM, swap can be useful during certain "shortcomings" as well as persistently saving some data even after shutdowns--or am I wrong in assuming that?

At one point, when I had disabled all swap and was only relying on my RAM, I had painfully difficult experiences trying to debug some system error, or crash, etc. Since then, I have re-enabled the swap partition. From Ubuntu Swap F. As a base minimum, it is highly recommended that the swap space should be equal to the amount of physical memory RAM.

Also, it is recommended that the swap space is twice the amount of physical memory RAM depending upon the amount of hard disk. I think you should increase your swap space in your system. The swap speeds up RAM memory allocation by allowing to discard already paged data. Sign up to join this community.

The best answers are voted up and rise to the top. Stack Overflow for Teams — Collaborate and share knowledge with a private group.

Create a free Team What is Teams? Learn more. Why use swap when there is more than enough free space in RAM? Ask Question. Asked 11 years, 1 month ago. Active 6 months ago. Viewed k times. Checkout my conky output below: Also, could this be the cause of speed and system-responsiveness issues I'm having? Improve this question. Bleeding Fingers 3 3 gold badges 11 11 silver badges 23 23 bronze badges.

Stefan Stefan 23k 39 39 gold badges 93 93 silver badges bronze badges. I'm pretty sure the dynamics of this issue have significantly changed with SSDs becoming the norm. SSD while slower is a lot cheaper and in most cases fast enough so even swapping shouldn't significantly disturb the user experience like it used to with rotational media.

Sometimes, if you used swap in the past because of full RAM, you can have a situation where previously swapped data stay there because it is not usefull data at the moment.

As Totor said. Sometimes the system will page something out for whatever reason. If later that page is moved back to memory for a read operation, the copy in swap space is not deleted. If the same page is later paged out again, without being changed, it can do so without writing to the disk again. The copy that is there is already up to date. In other words, a page can take up space both in swap and main memory. Add a comment. Active Oldest Votes.

To change the value temporarily lost on reboot : sudo sysctl vm. Improve this answer. Stephen Kitt k 43 43 gold badges silver badges bronze badges. Marcel Stimberg Marcel Stimberg 3, 1 1 gold badge 16 16 silver badges 14 14 bronze badges. Note that reducing swappiness does not necessarily mean a performance or responsiveness increase. I've seen reports of increasing swappiness translating into better performance.

Don't believe anything you read that doesn't include benchmarks, and check that the benchmarks use a workload similar to yours. Does this persist across reboot?

HandyGandy: I added information to the answer how to change it permanently. It doesn't exist on disk at all. Even setting it to 0, will continue to move crucial and frequently used pages e.

Show 1 more comment. Riccardo Murri Riccardo Murri By swapping out inactive programs, you have more memory for file caching. And that speeds things up. This is done to improve performance and responsiveness: Performance is increased because sometimes RAM is better used for disk cache than to store program memory. Gilles 'SO- stop being evil' Gilles 'SO- stop being evil' k gold badges silver badges bronze badges. So, in a sense, swap is an in-case measure?

That, and the hibernate thing? Tschepang: The OOM killer is the reason they crash. Technically you could do without an OOM killer and just not be able to allocate anything, but that would have a good chance of locking up the system; the OOM killer makes it a little more likely for the admin to be able to log in and for the important processes to keep running.

Far from nearly full, isn't it? Although a previous swapping caused by full RAM may have left this situation Linux will write to swap before RAM is full if your system is idling.

The clever bit is that if the system needs more RAM it can simply take the pages that have copy in the swap - otherwise those pages would be swapped at that moment. If the system needs more memory resources and the RAM is full, inactive pages in memory are moved to the swap space. While swap space can help machines with a small amount of RAM, it should not be considered a replacement for more RAM.

Swap space is located on hard drives, which have a slower access time than physical memory. Swap space can be a dedicated swap partition recommended , a swap file, or a combination of swap partitions and swap files.



0コメント

  • 1000 / 1000