find runtime stack usage size (not limit on stack) for a process for a single run

I have a need to determine the memory used by a library for its user stack. The library i  need to find this information about is zlib compression library. I linked this library statically with a small test program. I need to find how much stack growth is there during a single run of the program . Actually as i was going through this problem i ended up confusing myself. So i also would like to know whether the stack for process in unix can also end up being swaappped ?? .. I tried using gprof but it only gave me execution time profile ... are there tools in linux to determine memory usage .. also can the stack growth be monitored ? I would be grateful if i could receive some pointers in this regard.

Thanking you
Edara

edharaAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

edharaAuthor Commented:
Is there a better way of doing this than finding it out by running it through the debugger after studying the call graph all the while doing backtraces ??
0
yuzhCommented:
you can use:

pmap -l pid

to find out the memory usage details of a process.

man pmap to learn more.

Or use:

/usr/bin/ps -e -o pid,vsz,rss,comm

where:
vsz -- memory consumption (RAM + swap space)
rss -- memory consumption (RAM only)

man ps to learn more details




0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
edharaAuthor Commented:
Actually after posting the question i was inspired to try this out .. i used ulimit -s to play around with the stack size and found out that for stack sizes less than 8K my program gives a segmentation fault.. so i think 8k is a possible answer to the question ??

Also for the last ps post .. how do i get the pid of the process ..my process only runs for a few seconds .. by the time i run ps .. i cant find the process id .. ?? sorry for this dumb question .. but getting the answer from someone else is a lot better than thinking it out myself;)

Regards
Edara
0
edharaAuthor Commented:
hello all ..

 memusage -n exename

gives the entire details about max memory usage .. and mak stack size ..

Thanks for all the responses ... this site rocks ;)

Edara

0
edharaAuthor Commented:
i agree yuzh , you answered my question !! although the solution i need is something different.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Linux OS Dev

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.