Re: Memory usage on debian
On Fri, Jan 24, 2003 at 05:53:19PM -0500, Jason McCarty wrote:
> So, I understand the output of "free" and all that, but can anyone
> explain the behavior shown below? This after my computer has been up for
> a couple hours, doing very little. It usually shows this behavior,
> especially if I've run a lot of programs first. It seems like memory is
> being reclaimed from somewhere (kernel data? X11?) without free knowing
> about it.
>
> quaternion:~$ free
> total used free shared buffers cached
> Mem: 256104 251680 4424 0 67536 66640
> -/+ buffers/cache: 117504 138600
> Swap: 0 0 0
> quaternion:~$ ./src/crap
> zsh: killed ./src/crap
> quaternion:~$ free
> total used free shared buffers cached
> Mem: 256104 59900 196204 0 6828 13932
> -/+ buffers/cache: 39140 216964
> Swap: 0 0 0
The usual cause of this one is as follows: to start with, you have a
fairly quiet system with lots of data in the kernel's cache - see the
'buffers' and 'cached' entries - held there against the possibility that
it will be needed in the future. Then you run a program that asks for a
lot of memory. A program running now is of course more important than
data cached for the future, so, when it runs out of other memory to
allocate, the kernel throws that data away and gives the reclaimed
memory to your program. In fact, it eats through about 78Mb of the cache
like this before it exits.
When the program does finally exit, it hasn't really done anything
cacheable: the kernel can cache the executable itself, but nothing else.
Therefore, it just frees up all the formerly-cached memory your program
munched through. As time goes on, you'll probably see the count of used
memory start to swing back towards the previous steady state.
Cheers,
--
Colin Watson [cjwatson@flatline.org.uk]
Reply to: