Re: Memory, where's it going?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



    Hi Shaun :)

 * Shaun <[email protected]> dixit:
> I understand the concept and why things are cached, i've just never
> seen it cache this much before..

    That's probably because most of the work the machine did was CPU
bound and not IO bound. If you run many IO bound apps, which read a
lot from disk, you fill cache pretty fast. That's normal.

    For example, if your machine is an FTP server which most of the
time serves the same 10 files, only those files will end up filling
the cache, and the machine will not eat much memory caching. This
way, you probably end up with lots of unused memory, because it is
not needed even for cache.

    On the other hand, if your machine is an FTP server mostly
inactive but you serve a file whose size is 1GB, you will use most of
the memory with cache.

> My concern is that 
> with bearly anything running on it i already have dug into swap.

    Swap memory is not used just when the machine has no free memory.
Although this is a rough explanation and doesn't describe exactly the
swap mechanism, some apps will remain into swap space even if there's
plenty of free RAM available, as long as they are not used. And
that's good, because an unused app should not eat memory even if
there's free memory.

    Think about this situation: you have a running app whose memory
comsumption is cyclic, it eats most of the memory for a few minutes
and after that it frees the memory. The other apps eat a whole bunch
of memory, but they're sleeping, and only run once a day. In that
scenario, if apps were put out of swap and into main memory as soon
as free memory is available, the system will be very busy moving
sleeping apps from swap into core and back. And it will be wasted
time, because the moved apps are sleeping.

    What the kernel does is that it sents unused pages of memory to
swap when another app needs the memory (it is a bit more complex than
that, but it will do for an explanation), and after that it doesn't
put back the pages into main memory when it's free again. Instead, it
puts back the pages when they're accessed again, not before.

    Main memory must be used for things like running apps and
caching, not for storing sleeping apps. The system runs faster that
way, because it uses the expensive RAM to actually do work, not as a
drawer to put there apps "just in case they're needed" ;)

    Raúl Núñez de Arenas Coronado

-- 
Linux Registered User 88736 | http://www.dervishd.net
http://www.pleyades.net & http://www.gotesdelluna.net
It's my PC and I'll cry if I want to...
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[Index of Archives]     [Kernel Newbies]     [Netfilter]     [Bugtraq]     [Photo]     [Stuff]     [Gimp]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Video 4 Linux]     [Linux for the blind]     [Linux Resources]
  Powered by Linux