[gllug] Memory Available
Nix
nix at esperi.org.uk
Fri Apr 22 20:00:02 UTC 2005
On Thu, 21 Apr 2005, Andrew Halliwell spake:
> And verily, didst Steve Nelson announce to the hordes:
>> # free
>> total used free shared buffers cached
>> Mem: 2055472 1908656 146816 0 144056 1616668
>> -/+ buffers/cache: 147932 1907540
>> Swap: 2097112 13212 2083900
>>
>> How is this working under Linux? Is this memory available? If so why
>> is it not reported as free?
>
> It is free.
Well, the page cache isn't *technically* free; it takes work to free things
in there up, and you'll always have some space devoted to it (because all
mmap()ings, including text pages of running executables, reside there).
>> -/+ buffers/cache: 147932 1907540
> see that line? 1907540 is actual free memory.
> cache and buffers are used to the fullest by a system when the memory has no
> other use. You paid for the memory so why NOT use it to speed up your
> system's disk access by buffering/caching files?
The page cache does a lot more than that. It stores most mapped
pages. Some of those will be associated with files (e.g. the text pages
of executables), and some won't be (anonymous mappings); some pages will
be clean and discardable; some will be dirty and require swapping out;
some will be in use by more than one process. Some filesystems
(e.g. tmpfs) are allocated entirely from the page cache.
The page cache is the closest thing to a jack-of-all-trades in the
kernel. If you're doing something in kernel space, chances are the page
cache is involved somewhere.
(The buffer cache has rather more limited uses.)
> If some process suddenly requires the ram, the caches and buffers are freed
> to release it on demand.
... up to a point.
In this case I'd expect to see the space in the page cache devoted to
text pages of the JVM and libraries simply to stay there: either someone
else is using it, or someone likely will be, so why ditch it until
there's memory pressure?
The rest, well, some of it will be dirtied and swapped out pages, which
will simply be freed from swap, some will be allocated and swapped in
pages, which will temporarily revert to `free', some may be mmap()ed
files, which will stay in the page cache until pressure forces them out
just like the JVM's text pages, some may be anonymous mappings in the
page cache, which will be ditched immediately when no longer used, and
some may be allocated-but-not-touched (overcomitted) memory, which will
simply vanish like the dream it always was.
Let nobody tell you memory management is simple. :)
--
This is like system("/usr/funky/bin/perl -e 'exec sleep 1'");
--- Peter da Silva
--
Gllug mailing list - Gllug at gllug.org.uk
http://lists.gllug.org.uk/mailman/listinfo/gllug
More information about the GLLUG
mailing list