[collectd] memory.c and /proc/meminfo
octo at verplant.org
Thu Nov 17 22:44:41 CET 2005
On Thu, Nov 17, 2005 at 02:17:37PM -0600, Hanik, Filip wrote:
> I was getting really funky results, I found that this code worked
> better on Fedora Core 4.
how exactly were those results `funky'? All Linux 2.4/2.6 Boxes I've
seen so far worked perfectly fine..
> ---line 106 memory.c
> if (mem_used >= (mem_free + mem_buffered + mem_cached))
> //mem_used is the total, if mem_used is the biggest number
> mem_free = mem_free + mem_buffered + mem_cached;
> //mem_used -= mem_free + mem_buffered + mem_cached;
> mem_used -= mem_free;
> memory_submit (mem_used, mem_buffered, mem_cached, mem_free);
> Memory total, is the total of mem_free and mem_used
It's always a bit hard talking about memory utilization, mostly due to
an inconsistent nomenclature. When talking about `used' memory I mean
memory that's actually used by programs. `free' memory is space that's
actually idle, i.e. just sitting there and warming the room.
Given this definition the equation `free + used = total' is NOT true,
since the operating system will use some memory to buffer IO operations.
Under Linux the equation is `free + cached + buffered + used = total',
where `cached' and `buffered' are caches maintained by the kernel. I
won't get too much into Linux memory management, but if you're curious
you'll find many answers in the gentoo `FAQ Linux Memory Management'
Hope this raises the fog a bit ;) Regards,
P.S.: If anyone feels like getting confused, try to understand the
Solaris swap model ;) I hear that those values might be a little
`funky', but the guy telling me wasn't sure either ;)
Florian octo Forster
Hacker in training
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Size: 189 bytes
Desc: Digital signature
Url : http://mailman.verplant.org/pipermail/collectd/attachments/20051117/e3df1e36/attachment.pgp
More information about the Collectd