[net.unix-wizards] size of text/data space of running process

warren@picuxa.UUCP (Warren Burstein) (08/06/86)

How can one determine the amount of space taken up by a process,
broken up into text and data?  What is really wanted is
the total amount of core that will be taken up by many copies
of a shared-text process.  If you just add up the SZ's from "ps"
you count the text n times.

I read the SYS V source to ps, it seems it used to get this info
from the u structure on the pdp11 but no more, alas.

One suggestion is to get the text size from the "size" command
and assume that the rest of SZ is data (accounting for page size).
Does this work?

thanks in advance
warren
-- 

_  __  __
 |/  \/  \
 |___|___|/
 |
 |
 |
/

thomas@utah-gr.UUCP (Spencer W. Thomas) (08/10/86)

My understanding is that the SZ field of a ps listing is *only* data and
stack (assuming a pure-text program).  The text size is kept in the text
table (the 4.3 BSD ps will show TSIZ with the 'v' option).

I have tested this on 4.3, and find that there are processes with a
larger TSIZ than SIZE, so it is clear that the text is not included
there.  Whether this is true under System V (the original question was
for this version), I am not sure, but it shouldn't be hard to test.


-- 
=Spencer   ({ihnp4,decvax}!utah-cs!thomas, thomas@utah-cs.ARPA)

dave@murphy.UUCP (Dave Cornutt) (08/13/86)

Relay-Version: version B 2.10.1 6/24/83; site houligan.UUCP
Path: houligan!novavax!ucf-cs!peora!codas!akguc!akgua!gatech!seismo!columbia!caip!clyde!burl!ulysses!bellcore!whuxcc!lcuxlm!whuxl!whuxp!picuxa!warren
From: warren@picuxa.UUCP
Newsgroups: net.unix-wizards
Subject: size of text/data space of running process
Message-ID: <149@picuxa.UUCP>
Date: Wed, 6-Aug-86 16:58:52 EDT
Article-I.D.: picuxa.149
Posted: Wed Aug  6 16:58:52 1986
Date-Received: Wed, 13-Aug-86 03:34:02 EDT
Distribution: net
Organization: AT&T Information Systems, Parsippany N.J.
Lines: 24
Keywords: SYS V

In article <149@picuxa.UUCP>, warren@picuxa.UUCP types:

>How can one determine the amount of space taken up by a process,
>broken up into text and data [being run shared by several users]?
>...
>One suggestion is to get the text size from the "size" command
>and assume that the rest of [ps] SZ is data (accounting for page size).
>Does this work?

I'm not a SYS5 guru, but it should work.  In all of the UN*X implementations
that I'm aware, the size of the text segment is fixed at load time;
it doesn't change during execution.  Just subtract the text segment size
(as reported by "size") from the total size shown by ps for each process,
then add it back to the sum.

This assumes that the ls -N option wasn't used to link the program.  If
it was, the text is not shared.  If you don't know this, you can
determine it by doing "file <name-of-executable-file>" on the program.
If it says something that includes the words "pure executable", the
text is sharable.

---
"Pick it up and put it in your pocket, or somebody else will" - Stan Ridgeway

Dave Cornutt, Gould Computer Systems, Ft. Lauderdale, FL
UUCP:  ...{sun,pur-ee,brl-bmd}!gould!dcornutt
 or ...!ucf-cs!novavax!houligan!dcornutt
ARPA: wait a minute, I've almost got it...

"The opinions expressed herein are not necessarily those of my employer,
not necessarily mine, and probably not necessary."