I know Ubuntu manages memory autocratically, it stores cache on ram for quick program access, but every time I fill up the cache, it stays filled up, and Ubuntu it self cant delete the cache, if I open a program, the computer will slow down extremely. I have 16gb ram, I can use "sync && echo 3 | sudo tee /proc/sys/vm/drop_caches" to clear the cache, but only until its not filled up or I wont be able to open a terminal. This has happened from 12.04 to 13.10 with the same laptop, didnt happen with the previous laptop with the 12.04. How does Linux manage the in cache memory, how does he know when to delete? i have no idea how to fix this issue..
1 Answers
There is no need to manage, monitor or clear the Linux cache manually during normal operations, and no performance benefit in doing so.
The purpose of the cache is to store recently-accessed data from disk so that subsequent attempts to read it complete more quickly. This is why loading a large document is typically much faster the second time around. However, the memory is still considered "free" by Linux and can be re-used instantaneously if there is a need for more memory (e.g. you load a new program or document), so clearing the cache does not achieve anything. The drop_caches control is there to help developers with benchmarking and testing, not for ordinary users.
It is not possible to say what is causing your slow program loading without more information, but it almost certainly has nothing to do with the cache. Poor disk performance or the presence of other disk or CPU-intensive processes are possible culprits.
-
With the previous Ubuntu version's the system crashed every time the cache got fully filled, kernel panic and I could do nothing, after the update it simply "freezes" for some seconds before opening the programs. But it only happens when the cache is full. The memory is shown as free but the system can't use it, the drop caches unfreezes the computer when this happens, that’s why I thought it was cache related. What is the best way to diagnose the problem? I'm not a Linux guru but I usually find my way around Linux ( not just Ubuntu, even thought it doesn’t seem to happen on Kali or arch ). – fpinto Mar 25 '14 at 13:54
-
Assuming that you're using a stock kernel instead of some custom-build one, a kernel panic often indicates a hardware problem. Have you tried running a memory tester like Memtest86 to ensure that you don't have any bad memory? – Mar 25 '14 at 14:14
-
I have never tried a different kernel, I did run a memtest but a few months ago, I will try it again overnight. After more research I found this question http://askubuntu.com/questions/41778/computer-freezing-on-almost-full-ram-possibly-disk-cache-problem?rq=1 and I'm going to try it also. – fpinto Mar 25 '14 at 14:43