top or htop? Which one lies?

Mark Greenwood fatgerman at ntlworld.com
Sun Nov 8 12:29:28 GMT 2009


On Sunday 08 Nov 2009 08:55:08 Chris Jones wrote:
> 
> On 7 Nov 2009, at 10:54pm, Mark Greenwood wrote:
> 
> > I hope someone on here can clear this up.
> >
> > According to top my RAM is as follows:
> > 2060580k total,  1866728k used,  (which seems to me to be a  
> > ridiculously enormous amount of RAM to run a bare desktop)
> > According to htop (which I can't copy and paste)
> > 269/2012MB (which seems to me to be a quite miraculously small  
> > amount of RAM to run a bare desktop)
> >
> > Which one lies? And why the mahoosive discrepancy?
> 
> Neither. The difference is almost certainly the file cache.
> 
> ram access is much faster that disk access, and your linux kernel  
> knows this, so will use any 'unused' ram as a cache of all recently  
> accessed files, just in case you need them again. This means most  
> linux system will, after some time of usage, use what might seem like  
> a surprising large amount of ram, even when you aren't actually  
> running any applications.
> 
> The confusion comes because some ways of monitoring memory usage  
> include the file cache, others don't, since the ram used for the file  
> cache is only used as long as it is not needed for any other usage. As  
> soon as it is needed it will be given back. For me, the clearest  
> utility is the command line 'free' command.
> 
> So, my bet is your system is using 269MB of ram for real data storage,  
> and the difference between this and 1867MB is the file cache...
> 
> Chris
> 
> 
Thanks Guys, I knew there were never any simple answers :)

'free' gives me:
             total       used       free     shared    buffers     cached
Mem:       2060580     575336    1485244          0      27332     258848
-/+ buffers/cache:     289156    1771424
Swap:      6032368          0    6032368

Which appears to say I have 575336 (KB?) of RAM used, which is closer to what top is telling me today than to what htop is telling me. Another day, 3 different numbers :) Still at least you've cleared up my concern, I know what all that memory is being used for even if I don't know how much :-D

Cheers,

Mark



More information about the kubuntu-users mailing list