1834497 Members
2641 Online
110067 Solutions
New Discussion

Memory footprint command

 
SOLVED
Go to solution
Wei Pao
New Member

Memory footprint command

Hi,

Is there a HP-UX command that can be used to find out the memory footprint (resident set size) of a process?

Thanks.

WP
There is a will there is a way
9 REPLIES 9
A. Clay Stephenson
Acclaimed Contributor

Re: Memory footprint command

You can do this with Glance very easily but this should suffice:

UNIX95= ps -o vsz -p PID

notice the space after UNIX95= . That's important to define the XPG4 behavior of ps. Man ps for details.
If it ain't broke, I can fix that.
Wei Pao
New Member

Re: Memory footprint command

Hi Clay,

Does the vsz option give us the virtual memory size or the real-memory (resident set) size? Is there any other option we can use to get the other memory size in kilobytes?

Thanks a lot.

Wei
There is a will there is a way
Mike Stroyan
Honored Contributor
Solution

Re: Memory footprint command

The ps command only counts the size of the text, data, and stack regions. It can report a much smaller number than glance, which also counts shared libraries, shared and private mmap regions, and SYSV shared memory regions.
The ps option for resident set size is -o sz instead of -o vsz. The -sz report is RAM size measured in 4K pages. The -vsz report is virtual size reported in 1K units.
Shared regions make accounting more complicated. Glance discounts shared memory size by dividing by the total number of times a shared region is mapped.
The attached programs use pstat_getprocvm system calls to find the resident set size of all memory regions and then total them up. The procvm_sizes program counts shared regions as full size. The procvm_sizes_glance program discounts shared region sizes the same way glance does.
Mike Stroyan
Honored Contributor

Re: Memory footprint command

Hmm, my attachment didn't stick.
Here is another try.
Wei Pao
New Member

Re: Memory footprint command

Thank you, Mike!

Wei
There is a will there is a way
Geoff Wild
Honored Contributor

Re: Memory footprint command

Mike - how do you compile them?

I tried with native CC:

cc procvm_sizes.c
(Bundled) cc: "procvm_sizes.c", line 8: error 1705: Function prototypes are an ANSI feature.
(Bundled) cc: "procvm_sizes.c", line 44: error 1705: Function prototypes are an ANSI feature.
(Bundled) cc: "procvm_sizes.c", line 74: error 1705: Function prototypes are an ANSI feature.


Tried with gcc:

gcc procvm_sizes.c
In file included from procvm_sizes.c:5:
/opt/gcc/lib/gcc-lib/hppa2.0n-hp-hpux11.00/2.95.3/include/stdio.h:30: warning: `__va__list' redefined
/usr/include/sys/stdsyms.h:422: warning: this is the location of the previous definition
In file included from procvm_sizes.c:6:
/opt/gcc/lib/gcc-lib/hppa2.0n-hp-hpux11.00/2.95.3/include/stdlib.h:28: warning: `__va__list' redefined
/opt/gcc/lib/gcc-lib/hppa2.0n-hp-hpux11.00/2.95.3/include/stdio.h:30: warning: this is the location of the previous definition
as: "/var/tmp/ccuOC81b.s", line 28: error 1052: Directive name not recognized - NSUBSPA
as: "/var/tmp/ccuOC81b.s", line 229: error 1052: Directive name not recognized - NSUBSPA
as: "/var/tmp/ccuOC81b.s", line 387: error 1052: Directive name not recognized - NSUBSPA


Thanks...Geoff
Proverbs 3:5,6 Trust in the Lord with all your heart and lean not on your own understanding; in all your ways acknowledge him, and he will make all your paths straight.
Wei Pao
New Member

Re: Memory footprint command

I used "aCC" compiler. It worked.
However, "procvm_sizes_glance.c", line 122
s = malloc(sizeof(segment));
needs to be changed to
s = (shared_segment_struct *) malloc(sizeof(segment));

Wei

There is a will there is a way
Mike Stroyan
Honored Contributor

Re: Memory footprint command

Geoff,

I compile them with the HP ansi c compiler, /opt/ansic/bin/cc. They use ansi features, so they will not compile with the bundled /usr/ccs/bin/cc that is only intended for rebuilding kernel configuration files.

They also compile fine for me with gcc. It looks like you have a bad installation of gcc. Perhaps you could get around the gcc header file warning by applying a header file patch such as PHCO_26111 and then reinstalling gcc.
The error seems to come from using an incompatible 'as' assembler instead of 'gas'. You may find it easiest to install a new gcc from
http://h21007.www2.hp.com/dspp/tech/tech_TechSoftwareDetailPage_IDX/1,1703,547,00.html
Geoff Wild
Honored Contributor

Re: Memory footprint command

Found my issue - the person who installed gcc on the system I put your code on - installed gcc 2.95 for 11.0 - on a 11.i box....removed it and installed the one on the link you provided - works fine.

Thanks...Geoff
Proverbs 3:5,6 Trust in the Lord with all your heart and lean not on your own understanding; in all your ways acknowledge him, and he will make all your paths straight.