Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 324
  • Last Modified:

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

0
edhara
Asked:
edhara
  • 4
1 Solution
 
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
 
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

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

  • 4
Tackle projects and never again get stuck behind a technical roadblock.
Join Now