zoukankan      html  css  js  c++  java
  • linux手工释放内存

    先使用sync命令以确保文件系统的完整性,sync 命令运行 sync 子例程,将所有未写的系统缓冲区写到磁盘中,包含已修改的 i-node、已延迟的块 I/O 和读写映射文件。

    再执行下面任意一条命令:

    Writing to this file causes the kernel to drop clean caches,dentries and inodes from memory, causing that memory to becomefree.
    
    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 are not freeable, the user should run sync first.

    /proc是一个虚拟文件系统,我们可以通过对它的读写操作作为与kernel实体间进行通信的一种手段。也就是说可以通过修改/proc中的文件,来对当前kernel的行为做出调整。也就是说我们可以通过调整/proc/sys/vm/drop_caches来释放内存。

  • 相关阅读:
    python基础之数据类型
    简单猜年龄游戏
    python基础之变量
    Python3获取大量电影信息:调用API
    10分钟制作UWP汉堡菜单
    java 异常处理
    多态
    接口与继承
    数组及课后动手动脑
    String类型
  • 原文地址:https://www.cnblogs.com/trying/p/3447305.html
Copyright © 2011-2022 走看看