Experience: is what you get soon after you need it.

Experience: is what you get soon after you need it.

Rasul Allah (sal Allahu alaihi wa sallam) said: "Restore the trusts of those who trust you, and deal not falsely with him who deals falsely with you." [Abu Dawud, Tirmidhi]

Search This Blog

Friday, July 29, 2011

Unix memory leak issues.

If several crashes occur that have an associated large core file, then this is a good indication of a potential memory leak.


At any stage if you want to generate the core dump of an active process:

On Solaris:
-0 option is to manually give the path and filename for the core dump
gcore -o /obishared/obiqb/Lognode2/core.19199 19199
gcore: /obishared/obiqb/Lognode2/core.19199.19199 dumped




Start collecting memory consumption statistics.
Solaris

The prstat command can be used to gather basic performance data to help identify if there are any processes consuming a large amount

of memory. For example, the data below is sorted by the SIZE column. SIZE is the total virtual memory size of the process:

prstat -s size


AIX

The ps command can be used to show basic memory usage per process. For example, the data below is sorted by the VSZ column, the total

virtual memory size of the process in KB:

ps -efo "vsz,pid,user,cpu,thcount,comm" | sort –n


HP-UX

The top command can be used to show basic memory usage per process. For example, the SIZE column is the total virtual memory size of

the process in KB:

top

Linux

The ps command can be used to show basic memory usage per process. For example, the data below shows the memory being used by all the

siebmtshmw proceses in KB:


ps axo user,pid,vsz,thcount,cmd | grep siebmtshmw






If you are experiencing some of the symptoms described above or if you suspect a memory leak, it is particularly important that

performance data is captured so the memory leak can be confirmed. It is important to gather at least the following pieces of

information:


Process ID (PID)
Size of the process
The executing command
The timestamp information showing exactly when the data was captured.


One method of capturing this data is to use a shell script. The following are examples of shell scripts that can be used for the

various OS types:

Solaris

while true
do
for pid in `cat pids`
do var=`date|cut -d' ' -f4`
echo "$var :\c" >> ps.log.$pid
ps -eo pid,vsz,rss,pcpu,args | grep $pid |grep -v grep >> ps.log.$pid
done
sleep 30
done

AIX

while true
do
for pid in `cat pids`
do var=`date|cut -d' ' -f4`
echo "$var :\c" >> ps.log.$pid
ps -efo "pid,vsz,user,cpu,thcount,comm" | grep $pid |grep -v grep >> ps.log.$pid
done
sleep 30
done

HP-UX

while true
do
for pid in `cat pids`
do var=`date|cut -d' ' -f4`
echo "$var :\c" >> ps.log.$pid
ps -elf | grep $pid >> ps.log.$pid
done
sleep 30
done


Linux


while true
do
for pid in `cat pids`
do var=`date|cut -d' ' -f4`
echo "$var :\c" >> ps.log.$pid
ps axo pid,vsz,user,%cpu,thcount,cmd | grep $pid |grep -v grep >> ps.log.$pid
done
sleep 30
done


above are snippets from MOS.
References:

Note 477520.1 "How To Troubleshoot Siebel Server Component Crashes on UNIX". It is however possible for a process to crash as a result of a memory leak.
Note 477004.1 "How Can Users Prevent Core Files from Being Overwritten on UNIX Platforms?"

No comments: