{"id":1700,"date":"2009-03-27T18:00:52","date_gmt":"2009-03-27T22:00:52","guid":{"rendered":"http:\/\/blogs.n1zyy.com\/n1zyy\/?p=1700"},"modified":"2009-03-27T18:00:52","modified_gmt":"2009-03-27T22:00:52","slug":"handling-swap","status":"publish","type":"post","link":"https:\/\/blogs.n1zyy.com\/n1zyy\/2009\/03\/27\/handling-swap\/","title":{"rendered":"Handling Swap"},"content":{"rendered":"<p>Here&#8217;s a neat tip I picked up from Andrew. Have you ever run into a machine that won&#8217;t reclaim all of its swap? It turns out there&#8217;s an easy way to force a reclaim.<\/p>\n<p>First, a caveat. For most people, this makes no sense. If something is just sitting in swap even when there&#8217;s lots of free RAM, it means that whatever&#8217;s in swap is something that nothing, anywhere, cares about. It would have been reclaimed if anything tried to use it. You want to leave it in swap. And a second caveat: what I&#8217;m about to say is an <em>awful<\/em> idea if you don&#8217;t have lots of free RAM. But in cases where you&#8217;re using 4% swap and getting paged every 15 minutes because the monitoring system sees swap being used, and yet you have 5GB of free RAM, here&#8217;s a neat trick that will force everything in memory to be reclaimed.<\/p>\n<p>First, find the swap partition. On Linux, it&#8217;s &#8220;cat \/proc\/swaps,&#8221; though you could also look at fstab. GNOME and KDE users probably have a fancy GUI for this, but our servers don&#8217;t run GNOME. \ud83d\ude09 On the machine I just did this on, it was \/dev\/sda2, so I&#8217;ll use that as an example.<\/p>\n<p>Then, you &#8216;unmount&#8217; the swap partition, and then re-enable it. As you turn off the swap partition, its contents are forced back into memory. &#8220;swapoff \/dev\/sda2&#8221; to turn it off, and then &#8220;swapon \/dev\/sda2&#8221; to turn it back on.<\/p>","protected":false},"excerpt":{"rendered":"<p>Here&#8217;s a neat tip I picked up from Andrew. Have you ever run into a machine that won&#8217;t reclaim all of its swap? It turns out there&#8217;s an easy way to force a reclaim. First, a caveat. For most people, &hellip; <a href=\"https:\/\/blogs.n1zyy.com\/n1zyy\/2009\/03\/27\/handling-swap\/\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-1700","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/blogs.n1zyy.com\/n1zyy\/wp-json\/wp\/v2\/posts\/1700","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blogs.n1zyy.com\/n1zyy\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blogs.n1zyy.com\/n1zyy\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blogs.n1zyy.com\/n1zyy\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/blogs.n1zyy.com\/n1zyy\/wp-json\/wp\/v2\/comments?post=1700"}],"version-history":[{"count":0,"href":"https:\/\/blogs.n1zyy.com\/n1zyy\/wp-json\/wp\/v2\/posts\/1700\/revisions"}],"wp:attachment":[{"href":"https:\/\/blogs.n1zyy.com\/n1zyy\/wp-json\/wp\/v2\/media?parent=1700"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blogs.n1zyy.com\/n1zyy\/wp-json\/wp\/v2\/categories?post=1700"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blogs.n1zyy.com\/n1zyy\/wp-json\/wp\/v2\/tags?post=1700"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}