Hey thanks a ton for you directed me to the right place. PMAP helps.
But i need a little more push to get going :D.
Based on tests i believe that the stack memory is shared amoung processes.
so if there are 4 instances of the same process running parellely and the total stack memory of the OS is approx 8000k, each process will get 2000k before running out of stack. True pmap helps the current stack memory consumption for that PID, but if I wish to alert before the stack runs out of memory for that PID, I need to know what is the current free stack memory left on the operating system. Can you help me the know how to achieve this alert mechanism?
I'm pretty sure ulimit is controlling sizes of different structures for each process separately, not whole system. As for your output, I guess adding those values would be correct
Bartus agreed and thanks !!! Is it correct to say everything listed under ulimit -a is for each process seperately?
ulimit -a
core file size (blocks, -c) unlimited
data seg size (kbytes, -d) unlimited
file size (blocks, -f) unlimited
open files (-n) 1024
pipe size (512 bytes, -p) 10
stack size (kbytes, -s) 8192
cpu time (seconds, -t) unlimited
max user processes (-u) 29995
virtual memory (kbytes, -v) unlimited
Also, can you confirm that the stack for a PID is the sum of the complete pmap output shared above or just the last two lines, becoz for a process not doing much the sum of the stack shows Total used stack memory is:4680
Below is my code:
stackmem="$(pmap $1 | grep stack | awk '{print $2}'| tr -d ' K')"
n=0
for stack in $stackmem
do
n=`expr $n + $stack`
done
echo "Total used stack memory is:$n"
I guess we may have to discard the stack with the tids [ stack tid=2 ]
while summing the total stack memory used by a PID.
You can't discard stack segments with tid values as they are related to threads running as part of your process and as such are part of the process stack segments. I think you should increase the value in ulimit to allow your process to run with more stack segments. Another option is to redesign your application