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

Posted on 2003-03-26
Medium Priority
Last Modified: 2010-04-21
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

Question by:edhara
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4

Author Comment

ID: 8215048
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 ??
LVL 38

Accepted Solution

yuzh earned 750 total points
ID: 8215229
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

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

man ps to learn more details


Author Comment

ID: 8215596
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;)


Author Comment

ID: 8215633
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 ;)



Author Comment

ID: 8222770
i agree yuzh , you answered my question !! although the solution i need is something different.

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Have you ever been frustrated by having to click seven times in order to retrieve a small bit of information from the web, always the same seven clicks, scrolling down and down until you reach your target? When you know the benefits of the command l…
The purpose of this article is to fix the unknown display problem in Linux Mint operating system. After installing the OS if you see Display monitor is not recognized then we can install "MESA" utilities to fix this problem or we can install additio…
If you’ve ever visited a web page and noticed a cool font that you really liked the look of, but couldn’t figure out which font it was so that you could use it for your own work, then this video is for you! In this Micro Tutorial, you'll learn yo…
In this video, Percona Solution Engineer Dimitri Vanoverbeke discusses why you want to use at least three nodes in a database cluster. To discuss how Percona Consulting can help with your design and architecture needs for your database and infras…
Suggested Courses

771 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question