systemmonitor data engine: memory usage? (was: Re: System Monitor)

Dominik Haumann dhdev at gmx.de
Fri Dec 26 18:51:22 CET 2008


On Friday 26 December 2008, Aaron J. Seigo wrote:
> On Friday 26 December 2008, Dominik Haumann wrote:
> > Huhu,
> >
> > On Tuesday 23 December 2008, Aaron J. Seigo wrote:
> > > On Tuesday 23 December 2008, Dominik Haumann wrote:
> > > > into my mind are System Status, System Load Watcher, System Load
> > > > Viewer, TimeMon, System Essentials, System Usage, ...
> > >
> > > System Load Viewer is quite straight forward and "says it all" IMHO.
> > > =) hope to see this in 4.3!
> >
> > Agreed. I'll change this later so it's also reflected in the code.
> >
> > There still seems to be a problem with regard to calculating the memory
> > and cpu usage.
> >
> > 1. Memory
> >    total  = mem/physical/used + mem/physical/free
> >    used   = mem/physical/application
> >    cache  = mem/physical/cached
> >    buffer = mem/physical/buf
> >    kernel = mem/physical/used - mem/physical/application
> >                               - mem/physical/cached
> >                               - mem/physical/buf
> >
> >    Showing user, cache and buffer is straightforward. In KDE3's applet
> > we also had the kernel memory. This is missing and I'm calculating this
> > as above. What I draw then is not anymore in the contentsRect() (see
> > [1]), so probably calculation is wrong here (and the result looks a bit
> > different compared to what I got in KDE3).
> >    Is there any documentation of what exactly those mem/physical/*
> >    sources describe? It's unclear.
>
> John Tapsell probably knows this better than anyone else on this list,
> i'd imagine...

I've just been looking further into this: In KDE3's systemmonitor the 
sources came from /proc/meminfo and then the entry "Slab: %lu kB", and then 
the used memory is computed like this:
  sample.used = mtotal - mkernel - free - buffers - cached;
This "Slab" value [1] is not available from the systemmonitor. It usually 
doesn't grow over 20MB at all anyway. I don't know how important this value 
is, so is it a feasable solution to simply ignore this and only show used, 
cache and buffer?

Looking into KSysguardd's computation indeed reveales that it doesn't take 
this Slab value into account:

  scan_one( MemInfoBuf, "MemTotal", &Total );
  scan_one( MemInfoBuf, "MemFree", &MFree );
  scan_one( MemInfoBuf, "Buffers", &Buffers );
  scan_one( MemInfoBuf, "Cached", &Cached );
  Used = Total - MFree;
  Appl = ( Used - ( Buffers + Cached ) );

So simply using used, cached and buffers should do the trick. I think this 
solution is good enough, agreed?

Dominik

[1] Slab: in-kernel data structures cache


More information about the Plasma-devel mailing list