---
title: "Centos释放缓存"
author: "lam"
date: "2013-01-28T17:50:54Z"
tags: []
categories: ["操作系统"]
slug: "centos"
draft: false
lastmod: "2013-01-28T17:50:44Z"
id: 1776983
url: "https://lam.iteye.com/blog/1776983"
---

用centos的会发现，有时候系统处于空闲状态，但是内存全部被消耗。

其实这事是一个假象，内存不是真实的被消耗而只是被用作缓存，当系统有程序运行这些内存还是能够用于程序运行的。

如果想尽快释放缓存，可以使用以下命令。

为了使缓存里的数据不丢失，之前先运行一下以下命令
sync
# To free pagecache:
echo 1 > /proc/sys/vm/drop_caches
# To free dentries and inodes:
echo 2 > /proc/sys/vm/drop_caches
# To free pagecache, dentries and inodes:
echo 3 > /proc/sys/vm/drop_caches