Can we clear memory cache in Ubuntu
8,289
There is no need for this unless you are bench marking. It will slow the system for a few seconds while every resource is again loaded into the disk-cache.
To clear RAM Memory Cache (or page cache) ...
sudo -i
sync; echo 1 > /proc/sys/vm/drop_caches
Page cache
The page cache contains any memory mappings to blocks on disk. That could be buffered I/O, memory mapped files, paged areas of executables.
Related videos on Youtube
Comments
-
Bawantha over 1 year
In my Ubuntu 20.04 I see 8.7 GB Memory cache in system monitor. Can I clear this, what is the best way to do so?
-
24601 almost 3 yearsYou don't indicate what research you have done but does this reference answer your question?
-
HuHa almost 3 yearsWhy would you want to clear that cache? Are you about to do benchmarks, or what other reason do you have?
-
Bawantha almost 3 years@HuHa Actually I don't know whether I exactly needed or not. Months ago I had 8 GB RAM I upgrade it even that time I could work smoothly until my RAM gets full, now at this point I feel so much lag in my device I don't know why
-
HuHa almost 3 yearsRest assured that the Linux kernel makes the best possible use of your RAM. Those caches and file buffers are what really gives your system a huge boost; it's very much like running things from a RAM disk. But if you need more RAM for large applications, the kernel frees as many of those caches and file buffers as needed to fulfill your memory demands. It's best not to tinker with this; you will be hard-pressed to get a better result than what the kernel does all by itself.
-
HuHa almost 3 yearsMost likely it's the kernel NOT having that many caches and file buffers available (as RAM is needed for other things) that makes you feel a slowdown. It's better to check what processes are running that use a lot of RAM.
-