{"id":3738,"date":"2015-06-02T17:43:50","date_gmt":"2015-06-02T08:43:50","guid":{"rendered":"http:\/\/pchero21.com\/?p=3738"},"modified":"2015-06-02T17:43:50","modified_gmt":"2015-06-02T08:43:50","slug":"how-to-clear-memory-cache-in-linux","status":"publish","type":"post","link":"http:\/\/pchero21.com\/?p=3738","title":{"rendered":"How to clear memory cache in Linux"},"content":{"rendered":"<p>Linux \uc5d0\uc11c \uce90\uc2dc\ub41c \uba54\ubaa8\ub9ac\ub97c \uc5b4\ub5bb\uac8c \uc815\ub9ac\ud560 \uc218 \uc788\uc744\uae4c? \uacb0\ub860\uc801\uc73c\ub85c \uc138 \uac00\uc9c0 \ubc29\ubc95\uc73c\ub85c \uce90\uc2dc\ub41c \uba54\ubaa8\ub9ac \uc0ad\uc81c\uac00 \uac00\ub2a5\ud558\ub2e4.<\/p>\n<p>1. \ud398\uc774\uc9c0 \uce90\uc2dc \ud574\uc81c<\/p>\n<p>2. \ud574\uc81c \uac00\ub2a5 \uc624\ube0c\uc81d\ud2b8(dentry, inode) \ud574\uc81c<br \/>\n&#8211; dentry\uc5d0 \ub300\ud574\uc11c\ub294 \uc5ec\uae30(<a href=\"http:\/\/unix.stackexchange.com\/questions\/4402\/what-is-a-superblock-inode-dentry-and-a-file\" target=\"_blank\">http:\/\/unix.stackexchange.com\/questions\/4402\/what-is-a-superblock-inode-dentry-and-a-file<\/a>)\ub97c \ucc38\uc870\ud558\uc790.<\/p>\n<p>3. \ud574\uc81c \uac00\ub2a5 \uc624\ube0c\uc81d\ud2b8 + \ud398\uc774\uc9c0 \uce90\uc2dc \ud574\uc81c<\/p>\n<p>\uc544\ub798\ub294 \uce90\uc2dc\ub41c \uba54\ubaa8\ub9ac \ud574\uc81c\uc640 \uad00\ub828\ud55c \uc790\uc138\ud55c \ub0b4\uc6a9\uc774\ub2e4.(<a href=\"https:\/\/www.kernel.org\/doc\/Documentation\/sysctl\/vm.txt\" target=\"_blank\">https:\/\/www.kernel.org\/doc\/Documentation\/sysctl\/vm.txt<\/a>)<\/p>\n<blockquote>\n<pre>drop_caches\r\n\r\nWriting to this will cause the kernel to drop clean caches, as well as\r\nreclaimable slab objects like dentries and inodes.  Once dropped, their\r\nmemory becomes free.\r\n\r\nTo free pagecache:\r\n\techo 1 &gt; \/proc\/sys\/vm\/drop_caches\r\nTo free reclaimable slab objects (includes dentries and inodes):\r\n\techo 2 &gt; \/proc\/sys\/vm\/drop_caches\r\nTo free slab objects and pagecache:\r\n\techo 3 &gt; \/proc\/sys\/vm\/drop_caches\r\n\r\nThis is a non-destructive operation and will not free any dirty objects.\r\nTo increase the number of objects freed by this operation, the user may run\r\n`sync' prior to writing to \/proc\/sys\/vm\/drop_caches.  This will minimize the\r\nnumber of dirty objects on the system and create more candidates to be\r\ndropped.\r\n\r\nThis file is not a means to control the growth of the various kernel caches\r\n(inodes, dentries, pagecache, etc...)  These objects are automatically\r\nreclaimed by the kernel when memory is needed elsewhere on the system.\r\n\r\nUse of this file can cause performance problems.  Since it discards cached\r\nobjects, it may cost a significant amount of I\/O and CPU to recreate the\r\ndropped objects, especially if they were under heavy use.  Because of this,\r\nuse outside of a testing or debugging environment is not recommended.\r\n\r\nYou may see informational messages in your kernel log when this file is\r\nused:\r\n\r\n\tcat (1234): drop_caches: 3\r\n\r\nThese are informational only.  They do not mean that anything is wrong\r\nwith your system.  To disable them, echo 4 (bit 3) into drop_caches.<\/pre>\n<\/blockquote>\n<p>\uc2e4\uc81c\ub85c \uce90\uc2dc\ub97c \uc904\uc774\ub294 \uba85\ub839\uc5b4\ub294 \uc6d0\ud558\ub294 \ubaa8\ub4dc\uc5d0 \ub530\ub77c \uc544\ub798\uc640 \uac19\uc740 \ubc29\uc2dd\uc73c\ub85c \uc785\ub825\ud558\uba74 \ub41c\ub2e4.<\/p>\n<blockquote>\n<pre><code>$ echo 1 &gt; \/proc\/sys\/vm\/drop_caches<\/code><\/pre>\n<pre><code>$ echo 2 &gt; \/proc\/sys\/vm\/drop_caches<\/code><\/pre>\n<pre><code>$ echo 3 &gt; \/proc\/sys\/vm\/drop_caches<\/code><\/pre>\n<\/blockquote>\n<p>\ub2e4\uc74c\uc740 \ud14c\uc2a4\ud2b8 \uacb0\uacfc\uc774\ub2e4. \ud655\uc2e4\ud788 \uce90\uc2dc\ub41c \uba54\ubaa8\ub9ac\uac00 \uc904\uc5b4\ub4dc\ub294 \uac83\uc744 \ud655\uc778\ud560 \uc218 \uc788\ub2e4.<\/p>\n<p>&nbsp;<\/p>\n<blockquote><p>root@mywork:~# free -m<br \/>\ntotal\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 used\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 free\u00a0\u00a0\u00a0\u00a0 shared\u00a0\u00a0\u00a0 buffers\u00a0\u00a0\u00a0\u00a0 cached<br \/>\nMem:\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 7703\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 3618\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 4084\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 433\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 309\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 1239<br \/>\n-\/+ buffers\/cache:\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 2069\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 5633<br \/>\nSwap:\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 7627\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 7627<\/p>\n<p>root@mywork:~# echo 1 &gt; \/proc\/sys\/vm\/drop_caches<\/p>\n<p>root@mywork:~# free -m<br \/>\ntotal\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 used\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 free\u00a0\u00a0\u00a0\u00a0 shared\u00a0\u00a0\u00a0 buffers\u00a0\u00a0\u00a0\u00a0 cached<br \/>\nMem:\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 7703\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 2700\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 5003\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 432\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 641<br \/>\n-\/+ buffers\/cache:\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 2058\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 5644<br \/>\nSwap:\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 7627\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 7627<\/p><\/blockquote>\n<p>&nbsp;<\/p>\n<p>\ucc38\uc870: <a href=\"http:\/\/unix.stackexchange.com\/questions\/58553\/how-to-clear-memory-cache-in-linux\" target=\"_blank\">http:\/\/unix.stackexchange.com\/questions\/58553\/how-to-clear-memory-cache-in-linux<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Linux \uc5d0\uc11c \uce90\uc2dc\ub41c \uba54\ubaa8\ub9ac\ub97c \uc5b4\ub5bb\uac8c \uc815\ub9ac\ud560 \uc218 \uc788\uc744\uae4c? \uacb0\ub860\uc801\uc73c\ub85c \uc138 \uac00\uc9c0 \ubc29\ubc95\uc73c\ub85c \uce90\uc2dc\ub41c \uba54\ubaa8\ub9ac \uc0ad\uc81c\uac00 \uac00\ub2a5\ud558\ub2e4. 1. \ud398\uc774\uc9c0 \uce90\uc2dc \ud574\uc81c 2. \ud574\uc81c \uac00\ub2a5 \uc624\ube0c\uc81d\ud2b8(dentry, inode) \ud574\uc81c &#8211; dentry\uc5d0 \ub300\ud574\uc11c\ub294 \uc5ec\uae30(http:\/\/unix.stackexchange.com\/questions\/4402\/what-is-a-superblock-inode-dentry-and-a-file)\ub97c \ucc38\uc870\ud558\uc790. 3. \ud574\uc81c \uac00\ub2a5 \uc624\ube0c\uc81d\ud2b8 + \ud398\uc774\uc9c0 \uce90\uc2dc \ud574\uc81c \uc544\ub798\ub294 &hellip; <a href=\"http:\/\/pchero21.com\/?p=3738\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[25],"tags":[954,955,241,949],"_links":{"self":[{"href":"http:\/\/pchero21.com\/index.php?rest_route=\/wp\/v2\/posts\/3738"}],"collection":[{"href":"http:\/\/pchero21.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/pchero21.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/pchero21.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/pchero21.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=3738"}],"version-history":[{"count":5,"href":"http:\/\/pchero21.com\/index.php?rest_route=\/wp\/v2\/posts\/3738\/revisions"}],"predecessor-version":[{"id":3743,"href":"http:\/\/pchero21.com\/index.php?rest_route=\/wp\/v2\/posts\/3738\/revisions\/3743"}],"wp:attachment":[{"href":"http:\/\/pchero21.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=3738"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/pchero21.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=3738"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/pchero21.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=3738"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}