Mystery memory usage - what consumes my RAM?
I just started my system and logged on one user. I run top in a shell window under KDE and it shows nearly all of my 1GB of RAM in use. I can't see from the display what is using all that memmory. If you add up the memory under VIRT column, it comes nowhere near the amount shown as used.
Notice the 904496k total, 897056k used. Also, 28188k buffers. What are those and where are they and who is using them? Code:
top - 09:17:38 up 8:35, 1 user, load average: 0.00, 0.02, 0.00 This is what the free command shows: Code:
total used free shared buffers cached |
Also, this memory usage seems to be relatively static. There are variations over time, but not a lot really much. I ran watch -n 5 -d free and the changes were small and tended to average out over time; up a little, down a little, but no major change.
|
Hey, cool. I'm learning all kinds of new commands. Here is a screen of vmstat output with a line being written every five seconds.
vmstat 5 Code:
s@here:~$ vmstat 5 I still need someone to help me understand all this. |
while running top you can sort the columns. If you type M then the %MEM column will be sorted according to highest usage. If you type c then the command used for that process is listed. Type h for more help or man top from a terminal.
|
|
Thank you smoker for the tips on top. That's handy to know that top has many more commands.
Thanks for the link memory management info, Emerson. That's a good explanation. My system looked this way immediately after I booted, before I'd run any user programs besides X and the monitors themselves. So all the data that is stored in the RAM that is used by the cache must have been saved to disk somewhere and read in again during boot. Where is the disk copy of the cache saved? What tools exist to examine it and to tune it or modify it? Can it be deleted so the system starts clean with nothing (no data) from a past boot being loaded? |
Quote:
Maybe see if xrestop is any use in showing what the problem is. |
There isn't any "problem" here.
Look at this the way that Linux does: memory is a resource to be used, and used completely. It's the only thing in the system that's just as fast as the CPU itself. Even the fastest disk-drive is several orders of magnitude slower. So, Linux wants to use all of it, for something, all the time. If the chosen use is simply, "well, we might need this again sometime soon," and there's no other actual demand for memory manifesting itself anywhere, then Linux will happily use the memory for that purpose -- "well, why not?" Quite often, you see, there just isn't any competition for memory-space: no swapping is going on and it never will. So, Linux uses leftover memory for "buffers." When a request is made to read something from disk, it'll see if the information is already in a buffer. If so, no disk-I/O is required. And Linux will be absolutely, completely "lazy" about that... the memory will remain allocated until Doomsday, or until some competing use for the space actually appears. When the demand for memory does increase, if it ever does, then you'll see that Linux first begins to reduce the "buffer" allocation, then begins to be more aggressive about cleaning-up the so-called "working sets" of active processes, and only then, as a last resort, begins to swap in earnest. |
Exactly !
Here is my current top, this is with Azureus, Folding@home and firefox with multiple tabs and various panel applets and mysql and apache etc etc.... The machine is still relatively responsive but it's not using swap and almost all the memory is used. Don't worry about it unless you start seeing multiple megs of swap being used. Code:
[smoker@kids ~]$ top |
OK, all, I appreciate the info and tips and I understand. But... I still want to know what is in those allocated buffers and cache, if anything. My last question was
Quote:
Or am I just not getting this? Oh well. Time to go smoke a pipe. Frog Morton on the Town in an Altinok meer tonight, I think. Lagavulin and a splash of water on the side. |
All times are GMT -5. The time now is 06:33 PM. |