zoukankan      html  css  js  c++  java
  • zz Release memory in Linux (Unused or Cached)

    In computer science, Memory Leakage occurs when a computer software or program consumes required memory but unable to memory after completing its task or when no longer needed to Operating System. There are two types of Memory Leakage. One is Virtual Memory Leakage and another is Real Memory Leakage.

     

    Now first Identify cached memory or unused memory by executing,

     

    # free -m

     
    total
    used
    free
    shared
    Mem:
    3991
    2674
    1317
    0
    -/+ buffers/cache:
     
    753
    3238
     
    Swap:
    1023
    0
    1023
     
     

    Flush file system buffers by executing,

     

    # sync

     

    Kernels 2.6.16.x and newer versions of kernel provide a mechanism to have the kernel drop the page cache and/or inode and dentry caches on command, which can be helpful to free up a lot of memory.

     

    To free page cache:

    # echo 1 > /proc/sys/vm/drop_caches

     

    To free dentries and inodes:

    # echo 2 > /proc/sys/vm/drop_caches

     

    To free page cachedentries and inodes:

    echo 3 > /proc/sys/vm/drop_caches

     

    Above commands are non-destructive and will only release unused memory. As we have used sync, so it will flush all Dirty Objects which are not free able and make it as unused memory.

  • 相关阅读:
    paraview将csv格式显示为云图
    Valgrind安装与使用
    vscode+WSL+Debug+Cmake+OpenGL
    MFiX中DEM颗粒信息随时间变化
    origin添加两个Y轴
    conda回滚
    onedrive同步其他任意文件夹
    MFiX-DEM中的并行碰撞搜索
    MFiX-DEM中的串行碰撞搜索
    【Go】四舍五入在go语言中为何如此困难
  • 原文地址:https://www.cnblogs.com/geosky/p/Release_memory_in_Linux.html
Copyright © 2011-2022 走看看