当前位置:网站首页>Clean system cache and free memory under Linux

Clean system cache and free memory under Linux

2022-06-24 01:44:00 Introductory notes

When linux After reading files frequently , Physical memory will soon run out , When the program is finished , Memory will not be released normally , But all the time caching, Therefore, it is necessary to manually clean up the system cache to free memory .

sync

The operating system is running , The accessed files will be placed in buffer in . To avoid power failure , Data loss caused by faults such as , We need to take buffer Cache data in is written to disk

> sync;sync;sync

Do it manually sync command ( describe :sync The command runs sync Subroutines . If you have to stop the system , Then run sync Command to ensure file system integrity .sync Command to write all unwritten system buffers to disk , Include modified i-node、 Delayed block I/O And read-write mapping files

Manual memory release command

> echo 3>/proc/sys/vm/drop_caches

drop_caches The value of can be 0-3 Number between , It means different things :0: Don't release ( System default ) 1: Free page cache 2: Release dentries and inodes

Look at the memory

> free -h
total—— Total physical memory 
used—— Used memory , Generally, this value will be relatively large , Because this value includes cache+ Memory used by the application 
free—— Completely unused memory 
shared—— Application shared memory 
buffers—— cache , It's mainly used for catalogues ,inode It's worth waiting for (ls Large directories can see this value increase )
cached—— cache , For open files 

Restore default settings

Caching can improve the efficiency of the system , If you find that the system memory is often insufficient , You should consider adding memory , Instead of cleaning up often

> echo 0>/proc/sys/vm/drop_caches

Link to the original text :https://rumenz.com/rumenbiji/linux_drop_caches.html

原网站

版权声明
本文为[Introductory notes]所创,转载请带上原文链接,感谢
https://yzsam.com/2021/11/20211115203515480d.html

随机推荐