1.清理前内存使用情况 
free -m

2.开始清理  
echo 1 > /proc/sys/vm/drop_caches

3.清理后内存使用情况 
free -m

4.完成!

查看内存条数命令:

dmidecode | grep -A16 "Memory Device$"

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

# sync
# echo 1 > /proc/sys/vm/drop_caches
  echo 2 > /proc/sys/vm/drop_caches
  echo 3 > /proc/sys/vm/drop_caches

cache释放:
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

说明,释放前最好sync一下,防止丢数据。

因为LINUX的内核机制,一般情况下不需要特意去释放已经使用的cache。这些cache起来的内容可以增加文件以及的读写速度。
先说下free命令怎么看内存

[root@yuyii proc]# free

total   used   free     shared buffers cached
Mem: 515588 295452 220136 0      2060   64040
-/+ buffers/cache: 229352 286236
Swap: 682720 112 682608

其中第一行用全局角度描述系统使用的内存状况:
total——总物理内存
used——已使用内存,一般情况这个值会比较大,因为这个值包括了cache+应用程序使用的内存
free——完全未被使用的内存
shared——应用程序共享内存
buffers——缓存,主要用于目录方面,inode值等(ls大目录可看到这个值增加)
cached——缓存,用于已打开的文件
note:
    total=used+free
    used=buffers+cached (maybe add shared also)

第二行描述应用程序的内存使用:
前个值表示-buffers/cache——应用程序使用的内存大小,used减去缓存值
后个值表示+buffers/cache——所有可供应用程序使用的内存大小,free加上缓存值
note:
   -buffers/cache=used-buffers-cached
   +buffers/cache=free+buffers+cached

第三行表示swap的使用:
used——已使用
free——未使用

手动执行sync命令(描述:sync 命令运行 sync 子例程。如果必须停止系统,则运行 sync 命令以确保文件系统的完整性。sync 命令将所有未写的系统缓冲区写到磁盘中,包含已修改的 i-node、已延迟的块 I/O 和读写映射文件)

[root@server test]# echo 3 > /proc/sys/vm/drop_caches
[root@server test]# cat /proc/sys/vm/drop_caches
3

!将/proc/sys/vm/drop_caches值设为3

有关/proc/sys/vm/drop_caches的用法在下面进行了说明
/proc/sys/vm/drop_caches (since Linux 2.6.16)
Writing to this file causes the kernel to drop clean caches,
dentries and inodes from memory, causing that memory to become
free.

To free pagecache, use echo 1 > /proc/sys/vm/drop_caches; to
free dentries and inodes, use echo 2 > /proc/sys/vm/drop_caches;
to free pagecache, dentries and inodes, use echo 3 >
/proc/sys/vm/drop_caches.

Because this is a non-destructive operation and dirty objects

[svc][jk][mem]linux 内存清理/释放命令的更多相关文章

  1. linux 内存清理/释放命令

    1.清理前内存使用情况 free -m 2.开始清理  echo 1 > /proc/sys/vm/drop_caches 3.清理后内存使用情况 free -m 4.完成! 查看内存条数命令: ...

  2. linux memory release commands内存清理/释放命令

    linux 内存清理/释放命令 You could find reference from here: http://jingyan.baidu.com/article/597a06436a687f3 ...

  3. Linux内存(手动释放cache)

    项目的扩容申请了一台机器,到手之后看一下机器的指标,看到内存使用情况是这样的. 1.查看内存 free $ free -h total used free shared buffers cached ...

  4. 查看Linux内存状况的命令及工具

    1.cat  /proc/meminfo cat  /proc/<pid>/statm  和 cat  /proc/<pid>/status  获取特定的进程的内存信息: 2. ...

  5. linux 内存操作相关命令

    清理内存 echo 1 > /proc/sys/vm/drop_caches 查看内存使用情况 free –m 查看内存条数命令: dmidecode |grep -A16 "Memo ...

  6. Linux 内存清理

    1. Clear PageCache only.sync && echo 1 > /proc/sys/vm/drop_caches2. Clear dentries and in ...

  7. linux内存占用查看命令

    ps -e -o 'pid,comm,args,pcpu,rsz,vsz,stime,user,uid' | grep tomcat | sort -nrk5 其中rsz为实际内存,上例实现按内存排序 ...

  8. linux内存查看及释放

    查看内存 常用的查看内存工具有:top,ps,free,/proc/meminfo,/proc/$PID/status等,一般都指定了虚拟内存占用情况,但ps或/proc/$PID/status中RS ...

  9. Linux内存、性能诊断中vmstat命令的详解

    vmstat命令是最常见的Linux/Unix监控工具,可以展现给定时间间隔的服务器的状态值,包括服务器的CPU使用率,内存使用,虚拟内存 交换情况,IO读写情况.相比top,通过vmstat可以看到 ...

随机推荐

  1. error C2556: 'const char &MyString::operator [](int)' : overloaded function differs only by return type from 'char &MyString::operator [](int)'

    char & operator[](int i);const char & operator[](int i);/*const char & operator(int i);* ...

  2. devfs、sysfs、udev介绍

    转:http://www.360doc.com/content/11/1203/09/7378000_169310928.shtml 一.devfs linux下有专门的文件系统用来对设备进行管理,d ...

  3. c#中的??运算符

    注意啦,c#中的??运算符是和?:运算符是不同的,这两者是有区别的. ??运算符称为null合并运算符,用于定义null值的类型和引用类型的默认值. 只当运算符的左操作数不为 null,此运算符将返回 ...

  4. Java 定时任务 & 任务调度

    任务调度是指基于 给定时间点,给定时间间隔 或者 给定执行次数 自动执行任务. 方式1:通过 Thread 来实现 例如如下的代码,可以每隔 1000 毫秒做一次打印操作. public class ...

  5. pgfplots画二维图真的很方便,多例比较

    %直接PDFLATEX编译即可\documentclass[border=1mm]{standalone}\usepackage{tkz-euclide,pgfplots}\begin{documen ...

  6. pthread_join和pthread_detach的用法

    //从别处拷贝过来的,只作为自己查看方便,原作者不详,请谅解. 一:关于join join join是三种同步线程的方式之一.另外两种分别是互斥锁(mutex)和条件变量(condition vari ...

  7. [Todo]非常好的免费IT书籍资源 & Github排名

    今天看github排名,看到排在第二位的是免费书籍: https://github.com/vhf/free-programming-books/blob/master/free-programmin ...

  8. 安装pip源

    国内源地址: 豆瓣(douban) http://pypi.douban.com/simple/ 阿里云 http://mirrors.aliyun.com/pypi/simple/ 中国科技大学 h ...

  9. unity GI

    占坑 lightmapper有两种:  Enlighten, Progressive Enlighten: baked GI  静态物体 离线烘焙 precomputed GI 也是适用于静态物体 F ...

  10. POJ 2664 Prerequisites?(简单题)

    [题意简述]:k:已经选择的科目数:m:选择的科目类别:c:能够选择的科目数.r:要求最少选择的科目数量 在输入的k和m以下的一行是选择的科目号. 比如: 3 2 //3是他选择了3科.2表示选择了两 ...