Re: Disappearing RAM

Andi Kleen (ak@suse.de)
Mon, 23 Apr 2001 18:23:28 +0200


On Mon, Apr 23, 2001 at 11:58:37AM -0400, John Weber wrote:
>
> There appears to be quite a difference between the memory usage reported
> by top
> (immediately after boot and minus all user processes) and that reported
> by the kernel
> during boot. Can anyone give me any hints as to why this might happen?
>
> I am assuming that if I subtract all the memory in use by processes
> listed by top from all
> the memory in use that this equals the amount of memory used by the
> kernel.
> These numbers do not add up.

The view given by top is inaccurate because it has no way to detect shared
pages properly. This means for example that when you have glibc mapped into
all your N processes it counted N times its size, even though it only exists
once in memory. Worse it gets when you work with threaded programs; they
share their memory completely, but top/ps has no way to detect this and
counts the single shared process space for every process (I have an
experimental patch to fix the later problem)

In addition there are quite a bit of internal data structures in the kernel
which never appear in top, but eat memory. Most prominent of that is the
page table itself, which eats a few percent of your ram for a management
structure for every page (in 2.2 on 32bit ~40 bytes every 4K of memory;
in 2.4 it is much worse)

> A related question: In the 2.2 kernels, does the kernel pre-allocate
> any amount of memory
> for modules?

No.

-Andi
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/