Re: measuring shared memory on linux (was [Fwd: Re: /proc/*/statm, exactly what does "shared" mean?)]

[prev] [thread] [next] [Date index for 2005/02/15]

From: Steven Lembark
Subject: Re: measuring shared memory on linux (was [Fwd: Re: /proc/*/statm, exactly what does "shared" mean?)]
Date: 22:30 on 15 Feb 2005

>> Me too, but I'm not holding my breath.  We can find out how much total
>> memory is free though, at least on Linux.
>
> That particular information is far from being useful, since there is the
> cache. On my (linux) machine I have 0MB of free memory and 400-500MB of
> cached buffers. So on linux one needs to combine the two to get the
> answer. (see the output of free(1) on linux to see what I'm talking about)
>
> So what you are saying is that whatever the technique is to get that
> remaining free memory, if we have it we could just set a limit on how
> much "free" memory is available and start killing Apache procs, when that
> limit is passed. I think that might just work. The roughest approach will
> be to just kill the current process. The fine tuned one will be to
> maintain a table of proc sizes as I've suggested before.

Actually that's more complicated to compute than it looks
at first glance -- mainly due to shared copy-on-write
pages (vs.  IPC shared memory). The amount of RSS used
by any one of a process group can become runtime dependent
if any of the COW memory gets tickled.

Now add in issues of swapped proc's that may have lazy
evaluation of their COW pages; stir in a bit of lazy
swapping (which means that the O/S doesn't really know
how much swap is required until the deed goes down).
Net result is that the whole thing gets variable (if
not downright chaotic).

Given that the kernel is configured manage memory at
least semi-effeciently, setting a limit based on
sum(virtual - shared) + shared will usually work; it
just leaves the amount of acceptable swap use up to
the user. That use sum(RSS) as the cutoff, leaving
a fudge factor for shared (which tends to be fairly
consistent) and acceptable swap use.




        -- 
        Steven Lembark                                       85-09 90th Street
Workhorse Computing                                Woodhaven, NY 11421
lembark@xxxxxxx.xxx                                     1 888 359 3508

Re: measuring shared memory on linux (was [Fwd: Re: /proc/*/statm, exactly what does "shared" mean?)]
Steven Lembark 22:30 on 15 Feb 2005

Generated at 11:21 on 20 Feb 2005 by mariachi v0.52