[aclug-L] Re: Determining memory usage by a user
[Top] [All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
Once I tally (size)-(share) for all processes owned by User-X, then how do I
re-add the shared values only once per instance?
In other words, I want to count the shared memory once only, whether 1 or 25
processes use the shared area of memory.
Incidentally, /proc is where (at least certian implimentations of) proc/top
get their information, according to the reading I've done.
----- Original Message -----
From: "John Goerzen" <jgoerzen@xxxxxxxxxxxx>
Sent: Tuesday, June 08, 2004 1:00 PM
Subject: [aclug-L] Re: Determining memory usage by a user
> On Tue, Jun 08, 2004 at 10:42:35AM -0500, Jonathan Hall wrote:
> > If it is at all possible (I'm beginning to think it's not), I need to
> > way to determine how much memory a specific user is using.
> It is, but the trick is to first define what you mean by how much memory
> a specific user is using.
> The place to start is /proc. (See proc(5)). The statm file will be
> most useful. From the manpage:
> Provides information about memory status in pages. The
> size total program size
> resident resident set size
> share shared pages
> trs text (code)
> drs data/stack
> lrs library
> dt dirty pages
> I'm not sure exactly how those numbers tally with ps/top fields.
> You can probably use a formula such as (size - share) to obtain what you
> are after. Note that units may differ; you'll have to check on that. A
> page is 4K on i386 systems. The /proc/[number]/stat file also has
> fields that will probably interest you.
> If you are interested in this for enforcement purposes, the ulimit /
> setrlimit() features are probably what you want. They let the kernel do
> the calculating for you.
> -- John
> > My first thought was to add the values of the VSZ or RSS fields from
> > output. This, however, is worthless:
> > VSZ tells the entire 'virtual memory' usage by each process, which
> > shared memory. This means that a memory segment used by multiple
> > is counted multiple times. As an example of how worthless this is, if I
> > the VSZ values for every process on my router machine, the result is
> > of used memory. That machine has only 32mb of physical RAM and 32mb of
> > swap, so it is physically impossible for the used memory to ever exceed
> > 64mb.
> > The RSS value is also nearly-worthless, as it only reports 'resident'
> > (i.e. memory not in swap space). I have been unable to determine how
> > RSS value treats shared memory, but if I add all values in the RSS field
> > all processes, it always seems to roughly equal the amount of used
> > reported by 'free', so I think this value is close to accurate.
> > If I can find some way to determine how much swap space is used by a
> > (or all processes owned by a user), then I could possibly use the sum of
> > that value and the values of RSS from ps to come up with a reasonable
> > estimate for the total memory used by the user.
> > Can anyone think of a way to accomplish this?
> > -- Jonathan
> > -- This is the discussion@xxxxxxxxx list. To unsubscribe,
> > visit http://www.complete.org/cgi-bin/listargate-aclug.cgi
> -- This is the discussion@xxxxxxxxx list. To unsubscribe,
> visit http://www.complete.org/cgi-bin/listargate-aclug.cgi
-- This is the discussion@xxxxxxxxx list. To unsubscribe,