{"id":615,"date":"2013-03-18T16:13:18","date_gmt":"2013-03-18T22:13:18","guid":{"rendered":"http:\/\/vostorga.org\/?p=615"},"modified":"2013-03-18T16:13:18","modified_gmt":"2013-03-18T22:13:18","slug":"dropping-linux-memory-cache","status":"publish","type":"post","link":"https:\/\/vostorga.org\/?p=615","title":{"rendered":"Dropping Linux Memory Cache"},"content":{"rendered":"<p>A Linux server of my own executes from time to time an rsync script, which one it finishes up doing its magic, leaves behind a lot of stuff cached in memory.<\/p>\n<p>In order to &#8220;make available&#8221; the memory again to other applications, I recommend reading the following as seen on <a title=\"Drop Caches\" href=\"http:\/\/linux-mm.org\/Drop_Caches\" target=\"_blank\">linux-mm.org<\/a><\/p>\n<p><span style=\"font-size: 13px;\">Kernels 2.6.16 and newer provide a mechanism to have the kernel drop the page cache and\/or inode and dentry caches on command, which can help free up a lot of memory. Now you can throw away that script that allocated a ton of memory just to get rid of the cache&#8230;<\/span><\/p>\n<div dir=\"ltr\" id=\"content\" lang=\"en\">\n<p>\u00a0To use\u00a0<tt>\/proc\/sys\/vm\/drop_caches<\/tt>, just echo a number to it.<\/p>\n<p><em><strong>\u00a0To free pagecache:<\/strong><\/em><\/p>\n<blockquote>\n<pre># echo 1 &gt; \/proc\/sys\/vm\/drop_caches\r\n<a id=\"line-8\"><\/a><\/pre>\n<\/blockquote>\n<p><a id=\"line-9\"><\/a><a id=\"line-10\"><\/a><em><strong>To free directory entries and inodes:<\/strong><\/em><a id=\"line-11\"><\/a><a id=\"line-12\"><\/a><\/p>\n<blockquote>\n<pre># echo 2 &gt; \/proc\/sys\/vm\/drop_caches\r\n<a id=\"line-13\"><\/a><\/pre>\n<\/blockquote>\n<p><a id=\"line-14\"><\/a><a id=\"line-15\"><\/a><em><strong>To free pagecache, dentries and inodes:<\/strong><\/em><a id=\"line-16\"><\/a><a id=\"line-17\"><\/a><\/p>\n<blockquote>\n<pre>echo 3 &gt; \/proc\/sys\/vm\/drop_caches\r\n<a id=\"line-18\"><\/a><\/pre>\n<\/blockquote>\n<p><a id=\"line-19\"><\/a><a id=\"line-20\"><\/a>This is a non-destructive operation and will only free things that are completely unused. Dirty objects will continue to be in use until written out to disk and are not freeable. If you run &#8220;sync&#8221; first to flush them out to disk, these drop operations will tend to free more memory.<a id=\"line-21\"><\/a><\/p>\n<p>&nbsp;<\/p>\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>A Linux server of my own executes from time to time an rsync script, which one it finishes up doing its magic, leaves behind a lot of stuff cached in memory. In order to &#8220;make available&#8221; the memory again to other applications, I recommend reading the following as seen on linux-mm.org Kernels 2.6.16 and newer [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-615","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/vostorga.org\/index.php?rest_route=\/wp\/v2\/posts\/615"}],"collection":[{"href":"https:\/\/vostorga.org\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/vostorga.org\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/vostorga.org\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/vostorga.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=615"}],"version-history":[{"count":5,"href":"https:\/\/vostorga.org\/index.php?rest_route=\/wp\/v2\/posts\/615\/revisions"}],"predecessor-version":[{"id":620,"href":"https:\/\/vostorga.org\/index.php?rest_route=\/wp\/v2\/posts\/615\/revisions\/620"}],"wp:attachment":[{"href":"https:\/\/vostorga.org\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=615"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/vostorga.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=615"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/vostorga.org\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=615"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}