V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
V2EX 提问指南
acgeo
V2EX  ›  问与答

这样释放内存好吗? sync; echo 3 > /proc/sys/vm/drop_caches 会不会影响其他正在跑的程序?

  •  
  •   acgeo · 2015-01-08 16:19:55 +08:00 · 9220 次点击
    这是一个创建于 3608 天前的主题,其中的信息可能已经有所发展或是发生改变。

    会不会影响其他正在跑的程序?

    4 条回复    2015-01-20 15:43:13 +08:00
    pfitseng
        1
    pfitseng  
       2015-01-08 21:22:42 +08:00
    drop_caches

    Writing to this will cause the kernel to drop clean caches, as well as
    reclaimable slab objects like dentries and inodes. Once dropped, their
    memory becomes free.

    To free pagecache:
    echo 1 > /proc/sys/vm/drop_caches
    To free reclaimable slab objects (includes dentries and inodes):
    echo 2 > /proc/sys/vm/drop_caches
    To free slab objects and pagecache:
    echo 3 > /proc/sys/vm/drop_caches

    This is a non-destructive operation and will not free any dirty objects.
    To increase the number of objects freed by this operation, the user may run
    `sync' prior to writing to /proc/sys/vm/drop_caches. This will minimize the
    number of dirty objects on the system and create more candidates to be
    dropped.

    This file is not a means to control the growth of the various kernel caches
    (inodes, dentries, pagecache, etc...) These objects are automatically
    reclaimed by the kernel when memory is needed elsewhere on the system.

    Use of this file can cause performance problems. Since it discards cached
    objects, it may cost a significant amount of I/O and CPU to recreate the
    dropped objects, especially if they were under heavy use. Because of this,
    use outside of a testing or debugging environment is not recommended.

    You may see informational messages in your kernel log when this file is
    used:

    cat (1234): drop_caches: 3

    These are informational only. They do not mean that anything is wrong
    with your system. To disable them, echo 4 (bit 3) into drop_caches.
    pfitseng
        2
    pfitseng  
       2015-01-08 21:22:53 +08:00
    zts1993
        3
    zts1993  
       2015-01-08 21:27:51 +08:00
    释放caches不是释放内存。。只会让你的程序更慢。。
    guotie
        4
    guotie  
       2015-01-20 15:43:13 +08:00
    不会。
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   实用小工具   ·   5223 人在线   最高记录 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 27ms · UTC 01:28 · PVG 09:28 · LAX 17:28 · JFK 20:28
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.