简体   繁体   中英

How to remove a data from main memory/RAM

Is there any way to remove a specific data from the main memory in Linux ? So that is has to bring again that data from the hard-disk

Rather than removing a specific piece of data, this will remove all from the linux cache. (I am assuming this is what you mean when you want linux to reload a file from the hard disk into main memory).

sudo sh -c "sync; echo 3 > /proc/sys/vm/drop_caches"

Link: How to clear memory cache on linux

Also, my apologies to Mohit M. as he answered this in the comment section before me.

You could always change your app to use O_DIRECT flag which bypasses the page cache and fetches file from diskc for a specific read call. Now it may not work in all cases (especially in case of stacked block devices etc) in which case you should stick to drop_caches like other before me explained.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM