2

I have this situation with RAM and SWAP at the moment:

$ free -h
             total       used       free     shared    buffers     cached
Mem:          7,7G       7,5G       159M       100M        75M       5,9G
-/+ buffers/cache:       1,5G       6,1G
Swap:         7,9G       408M       7,5G

And I was wondering...

Is there a way to know what programs/data are RAM-cached and/or from which process do they come from?

Thank you very much in advance.

EDIT: to know the programs/data in SWAP follow the link provided by @xubu-tur .

dadexix86
  • 6,616
  • I think if you run 'ps aux' and look at the column VSZ you'll find out. However there is no reason to worry about buffer or cache. This is performed by the OS itself and won't make your system run out of memory. Look here: http://askubuntu.com/questions/441928/memory-is-taken-up-by-invisible-threads – Reza May 10 '14 at 10:02
  • I know what cache is and (more or less) how it works, it is just curiosity about the cached processes :) As I understood, ps axu shows the active processes, but not the dead and cached ones, nor the cached data relative to a non-existing process. – dadexix86 May 10 '14 at 10:21
  • Perhaps this http://stackoverflow.com/a/7180078 – TuKsn May 10 '14 at 10:32
  • This is really useful for the Swap indeed, thanks! – dadexix86 May 10 '14 at 11:03
  • Any ideas for the cached things? :) – dadexix86 May 11 '14 at 09:37
  • I am not sure how to seperate them from gui , but from ubuntu system monitor you can see a graph with ram and swap .If you go to processes you can see how much ram it takes for every process .It is a live interaction , so if a process needs more you will see it changing and that how you know that process is active – billybadass May 12 '14 at 18:55
  • So... No guesses for cached data? This is bad :( – dadexix86 May 14 '14 at 18:23
  • 1
    Take a look at this very similar question: http://stackoverflow.com/questions/210809/how-can-you-tell-whether-a-file-is-being-cached-in-memory-in-linux – bseibold May 15 '14 at 21:55

1 Answers1

5

The same question was asked at LinuxQuestions.org: http://www.linuxquestions.org/questions/linux-general-1/command-to-check-process-taking-high-cached-memory-927756/

The important part of the answer is:

Cache isn't associated with a process per se, it is related to I/O on your system.

Linux tries to cache as much I/O data as it can. If that data needs to be read in the future, it is already in storage. Cache is a mechanism to avoid doing real I/O operations as real I/O to a disk is very slow compared to just retrieving it from memory. So a high cache number is generally good and nothing to be concerned with.

So, no you can't know which programs or processes are in cache, becasue there are no such items there.

What you can find there is cached I/O, and as @bseiblod mentioned in his comment, you can find a solution to that here: How can you tell whether a file is being cached in memory in linux?