4.3 修改/proc/sys/vm/drop_caches:
echo 3 > /proc/sys/vm/drop_caches
说明:
1)/proc是一个虚拟文件系统,我们可以通过对它的读写操作作为与kernel实体间进行通信的一种手段。也就是说可以通过修改/proc中的文件,来对当前kernel的行为做出调整。也就是说我们可以通过调整/proc/sys/vm/drop_caches来释放内存。
2)drop_caches:
Writing to this file causes the kernel to drop cleancaches,dentries and inodes from memory, causing that memory tobecomefree.
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 arenot freeable, the user should run syncfirst.
Linux基础篇之内存管理机制(2)
内容版权声明:除非注明,否则皆为本站原创文章。