{"id":481,"date":"2023-01-16T22:41:00","date_gmt":"2023-01-17T04:41:00","guid":{"rendered":"http:\/\/blog.supportpro.com\/?p=481"},"modified":"2026-03-26T00:05:46","modified_gmt":"2026-03-26T06:05:46","slug":"clear-cache-memory-in-linux-without-rebooting","status":"publish","type":"post","link":"https:\/\/www.supportpro.com\/blog\/clear-cache-memory-in-linux-without-rebooting\/","title":{"rendered":"Clear Cache Memory in Linux Without Rebooting"},"content":{"rendered":"\n<p>Linux automatically uses available RAM for disk caching to improve performance. However, during troubleshooting, benchmarking, or memory-related issues, you may need to <strong>manually clear cache in Linux without rebooting<\/strong>.<\/p>\n\n\n\n<p>This guide explains how to safely clear:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Page cache<\/li>\n\n\n\n<li>Dentries<\/li>\n\n\n\n<li>Inodes<\/li>\n<\/ul>\n\n\n\n<p>Using the <code>vm.drop_caches<\/code> kernel parameter via the <code>sysctl<\/code> command.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Understanding Linux Cache Memory<\/h2>\n\n\n\n<p>Linux uses three primary types of cache:<\/p>\n\n\n\n<figure class=\"wp-block-table\"><div class=\"pcrstb-wrap\"><table class=\"has-fixed-layout\"><thead><tr><th>Cache Type<\/th><th>Description<\/th><\/tr><\/thead><tbody><tr><td><strong>Page Cache<\/strong><\/td><td>Stores file data to speed up disk reads<\/td><\/tr><tr><td><strong>Dentries<\/strong><\/td><td>Directory entry cache<\/td><\/tr><tr><td><strong>Inodes<\/strong><\/td><td>Metadata about files<\/td><\/tr><\/tbody><\/table><\/div><\/figure>\n\n\n\n<p>This caching improves performance. Clearing it unnecessarily can temporarily reduce system efficiency.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">When Should You Clear Cache in Linux?<\/h2>\n\n\n\n<p>Clearing cache is useful when:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Troubleshooting memory issues<\/li>\n\n\n\n<li>Testing application performance<\/li>\n\n\n\n<li>Benchmarking disk performance<\/li>\n\n\n\n<li>Freeing memory in development environments<\/li>\n\n\n\n<li>Resoling abnormal RAM usage spikes<\/li>\n<\/ul>\n\n\n\n<p><strong>Note:<\/strong> On production systems, clearing cache may temporarily degrade performance.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">How to Clear Cache in Linux Without Rebooting<\/h2>\n\n\n\n<h3 class=\"wp-block-heading\">Step 1: Sync Cached Data to Disk<\/h3>\n\n\n\n<p>Before clearing cache, flush pending writes:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sync<\/code><\/pre>\n\n\n\n<p>This ensures all modified data is written to disk.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Step 2: Clear Cache Using sysctl<\/h3>\n\n\n\n<p>Run the following command as root:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sync &amp;&amp; sudo sysctl -w vm.drop_caches=3<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">What This Does:<\/h3>\n\n\n\n<ul class=\"wp-block-list\">\n<li><code>vm.drop_caches=1<\/code> \u2192 Clears Page Cache<\/li>\n\n\n\n<li><code>vm.drop_caches=2<\/code> \u2192 Clears Dentries &amp; Inodes<\/li>\n\n\n\n<li><code>vm.drop_caches=3<\/code> \u2192 Clears All (Page Cache + Dentries + Inodes)<\/li>\n<\/ul>\n\n\n\n<h3 class=\"wp-block-heading\">Step 3: Reset drop_caches Parameter<\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo sysctl -w vm.drop_caches=0<\/code><\/pre>\n\n\n\n<p>This stops further cache clearing.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Alternative Method (Using \/proc Interface)<\/h2>\n\n\n\n<p>You can also clear cache directly:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sync &amp;&amp; echo 3 | sudo tee \/proc\/sys\/vm\/drop_caches<\/code><\/pre>\n\n\n\n<p>This achieves the same result as sysctl.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Verify Memory Usage Before and After<\/h2>\n\n\n\n<p>Check memory usage:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>free -h<\/code><\/pre>\n\n\n\n<p>Or:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>cat \/proc\/meminfo<\/code><\/pre>\n\n\n\n<p>Look for changes in:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Cached<\/li>\n\n\n\n<li>Buffers<\/li>\n\n\n\n<li>Available memory<\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\">Important Considerations<\/h2>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Linux automatically manages memory efficiently.<\/li>\n\n\n\n<li>Clearing cache does NOT permanently free RAM.<\/li>\n\n\n\n<li>Cache will rebuild as applications access disk.<\/li>\n\n\n\n<li>Avoid scheduling frequent cache clearing on production systems.<\/li>\n\n\n\n<li>Always use <code>sync<\/code> before dropping caches.<\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\">Best Practice for Production Servers<\/h2>\n\n\n\n<p>Instead of manually clearing cache:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Investigate high memory usage using <code>top<\/code> or <code>htop<\/code><\/li>\n\n\n\n<li>Check for memory leaks<\/li>\n\n\n\n<li>Optimize application memory limits<\/li>\n\n\n\n<li>Review swap usage<\/li>\n\n\n\n<li>Monitor I\/O activity with <code>iotop<\/code><\/li>\n<\/ul>\n\n\n\n<p>Cache clearing should be a troubleshooting step; not a routine maintenance task.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Summary<\/h2>\n\n\n\n<p>You can clear cache in <a href=\"https:\/\/www.supportpro.com\/blog\/adminer\/\" title=\"\">Linux <\/a>without rebooting using:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sync &amp;&amp; sudo sysctl -w vm.drop_caches=3<\/code><\/pre>\n\n\n\n<p>This clears page cache, dentries, and inodes instantly. However, use it cautiously, especially on production servers.<\/p>\n\n\n\n<p>It&#8217;s important to use this method with caution and follow the instructions carefully, if you have any doubts, contact <a href=\"https:\/\/supportpro.com\/requestquote.php\">SupportPRO Server Admin<\/a> for help.<\/p>\n\n\n\n<div class=\"wp-block-media-text alignwide has-media-on-the-right is-stacked-on-mobile is-vertically-aligned-center has-white-background-color has-background\"><div class=\"wp-block-media-text__content\">\n<p class=\"has-large-font-size\">Facing issues? <\/p>\n\n\n\n<p class=\"has-large-font-size\">Our technical support<br>engineers can solve it. <\/p>\n\n\n\n<!--HubSpot Call-to-Action Code --><span class=\"hs-cta-wrapper\" id=\"hs-cta-wrapper-3350a795-db50-482f-9911-301930d1b1be\"><span class=\"hs-cta-node hs-cta-3350a795-db50-482f-9911-301930d1b1be\" id=\"hs-cta-3350a795-db50-482f-9911-301930d1b1be\"><!--[if lte IE 8]><div id=\"hs-cta-ie-element\"><\/div><![endif]--><a href=\"https:\/\/cta-redirect.hubspot.com\/cta\/redirect\/2725694\/3350a795-db50-482f-9911-301930d1b1be\" ><img decoding=\"async\" class=\"hs-cta-img\" id=\"hs-cta-img-3350a795-db50-482f-9911-301930d1b1be\" style=\"border-width:0px;\" src=\"https:\/\/no-cache.hubspot.com\/cta\/default\/2725694\/3350a795-db50-482f-9911-301930d1b1be.png\"  alt=\"Contact Us today!\"\/><\/a><\/span><script charset=\"utf-8\" src=\"https:\/\/js.hscta.net\/cta\/current.js\"><\/script><script type=\"text\/javascript\"> hbspt.cta.load(2725694, '3350a795-db50-482f-9911-301930d1b1be', {\"useNewLoader\":\"true\",\"region\":\"na1\"}); <\/script><\/span><!-- end HubSpot Call-to-Action Code -->\n<\/div><figure class=\"wp-block-media-text__media\"><img fetchpriority=\"high\" decoding=\"async\" width=\"904\" height=\"931\" src=\"https:\/\/www.supportpro.com\/blog\/wp-content\/uploads\/2022\/09\/Free-server-checkup.png\" alt=\"guy server checkup\" class=\"wp-image-12943 size-full\" srcset=\"https:\/\/www.supportpro.com\/blog\/wp-content\/uploads\/2022\/09\/Free-server-checkup.png 904w, https:\/\/www.supportpro.com\/blog\/wp-content\/uploads\/2022\/09\/Free-server-checkup-291x300.png 291w, https:\/\/www.supportpro.com\/blog\/wp-content\/uploads\/2022\/09\/Free-server-checkup-768x791.png 768w, https:\/\/www.supportpro.com\/blog\/wp-content\/uploads\/2022\/09\/Free-server-checkup-585x602.png 585w\" sizes=\"(max-width: 904px) 100vw, 904px\" \/><\/figure><\/div>\n","protected":false},"excerpt":{"rendered":"<p>Linux automatically uses available RAM for disk caching to improve performance. However, during troubleshooting, benchmarking, or memory-related issues, you may need to manually clear cache in Linux without rebooting. This&hellip;<\/p>\n","protected":false},"author":13,"featured_media":13039,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_lmt_disableupdate":"","_lmt_disable":"","footnotes":""},"categories":[91],"tags":[50,106],"class_list":["post-481","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-linux","tag-business-intelligence","tag-server"],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/www.supportpro.com\/blog\/wp-json\/wp\/v2\/posts\/481","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.supportpro.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.supportpro.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.supportpro.com\/blog\/wp-json\/wp\/v2\/users\/13"}],"replies":[{"embeddable":true,"href":"https:\/\/www.supportpro.com\/blog\/wp-json\/wp\/v2\/comments?post=481"}],"version-history":[{"count":8,"href":"https:\/\/www.supportpro.com\/blog\/wp-json\/wp\/v2\/posts\/481\/revisions"}],"predecessor-version":[{"id":15883,"href":"https:\/\/www.supportpro.com\/blog\/wp-json\/wp\/v2\/posts\/481\/revisions\/15883"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.supportpro.com\/blog\/wp-json\/wp\/v2\/media\/13039"}],"wp:attachment":[{"href":"https:\/\/www.supportpro.com\/blog\/wp-json\/wp\/v2\/media?parent=481"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.supportpro.com\/blog\/wp-json\/wp\/v2\/categories?post=481"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.supportpro.com\/blog\/wp-json\/wp\/v2\/tags?post=481"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}