Oracle Point, Oracle Life.

Most Popular Posts

May 10, 2010

How to Verify Memory Leaks on Unix

Filed under: OraclePoint, Oracle Utilities — R.Wang @ 4:12 pm

Recently, we were experiencing memory usage problem while we created a domain index (Oracle Text). The circumstance we are facing is that the memory was eaten up shortly after we started the simple create domain index statement.

As we known, creating that domain index probably would takes over 2 days. It’s also what we’ve been told by application vendor. After we started the process to create that domain index, we monitored it by using solaris command “prstat” and noticed that the value of column ‘SIZE’ was increasing continuously. The investigation we made in Toad also presented that the “PGA_ALLOC_MEM” kept increasing crazily. And shortly, only this single process took over 8G on “PGA_ALLOC_MEM”. Upon this, we doubt that that’s a memory leaks.

Before we start to overcome it, we need to verify if that’s memory leaks first. Thanks for oracle metalink article Note: 477522.1 How To Troubleshoot Memory Leaks on UNIX , we are able to easily verify it with given script.

The first step is to create a solaris shell script as following, named mem.shl.

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

And then, establish sqlplus connection to database and use SPID of this oracle session as input content of file pids.

29195

Okay, we are now ready to create domain index within above oracle session. Shortly after the issuing of create index command, please start mem.shl script to monitor that process.

sh mem.shl

While the create index command is running, you’ll be noticed that there is output file created, called ps.log.19704. The shell script mem.shl will produce memory calculation every 30 seconds and write it to file ps.log.19704. The typical output of file ps.log.29195looks like below.

7 :29195 1400848 1384184  4.2 oracleWEBCT (LOCAL=NO)
7 :29195 1581008 1564296 10.5 oracleWEBCT (LOCAL=NO)
7 :29195 1758928 1742264 11.6 oracleWEBCT (LOCAL=NO)
7 :29195 1933328 1916648 12.1 oracleWEBCT (LOCAL=NO)
7 :29195 2100432 2083728 11.9 oracleWEBCT (LOCAL=NO)
7 :29195 2281232 2264552 12.0 oracleWEBCT (LOCAL=NO)
7 :29195 2459920 2443248 12.2 oracleWEBCT (LOCAL=NO)
7 :29195 2641616 2624904 12.3 oracleWEBCT (LOCAL=NO)
7 :29195 2824144 2807448 12.2 oracleWEBCT (LOCAL=NO)
7 :29195 3004496 2987824 12.1 oracleWEBCT (LOCAL=NO)

From output above (the column in color red), it’s very clear that the memory consumption is increasing linearly. That’s for sure is memory leaks.

For intuitive perspective, it’s better to create PivotTable in Microsoft Office Excel. Basically, the figure 1 below shows typical memory leaks and figure 2 presents normal memory usage. Usually, the memory leak process starts up and grows to specific amount of memory usage for a period of time and, at one point of time, memory growth rises sharply to quite larger size of memory, like plotted in figure 1.

image

Figure 1. Process with Memory Leak

image

Figure 2. Process without memory Leak

For similar solution for other version of Unix, please refer to oracle metalink.

bookmark bookmark bookmark bookmark bookmark bookmark bookmark bookmark bookmark bookmark bookmark bookmark bookmark bookmark bookmark bookmark

Popularity: 6% [?]

Tags:, ,

April 23, 2009

Using Crontab to Create Statspack Reports

Filed under: OraclePoint, Oracle Utilities — R.Wang @ 6:23 pm

In versions before Oracle 10g, statspack is useful utility to monitor database performance and workload issues. I just came across a shell script which can automate snapshot report create and mail to DBA.

The script is re-posted as below without change.

[oracle@www1 sql]$ more backup/auto_send_perf.sh
#!/bin/sh
. ~oracle/.bash_profile

/home/oracle/product/9.2.0/bin/sqlplus -s aaa/bbb@ccc<<!
set head off
set timing off
spool /home/oracle/sql/backup/snap_begin.lst
select min(snap_id) snap_id
from stats$snapshot
where snap_time between trunc(sysdate) and trunc(sysdate)+1;
spool off
spool /home/oracle/sql/backup/snap_end.lst
select max(snap_id) snap_id
from stats$snapshot
where snap_time between trunc(sysdate) and trunc(sysdate)+1;
spool off
exit
!

BEGIN_SNAP=`cat /home/oracle/sql/backup/snap_begin.lst | tail -n 2`
END_SNAP=`cat /home/oracle/sql/backup/snap_end.lst | tail -n 2`
#END_SNAP=`expr $BEGIN_SNAP + 13`
REPORT_NAME=/home/oracle/sql/report/sp`date +%m%d`_ac

/home/oracle/product/9.2.0/bin/sqlplus -s aaa/bbb@ccc<<!
define begin_snap=$BEGIN_SNAP
define end_snap=$END_SNAP
define report_name=$REPORT_NAME
@?/rdbms/admin/spreport
exit
!

mail -s “perfstat report” ddd@eee.fff < /home/oracle/sql/report/sp`date +%m%d`_ac.lst

[oracle@www1 sql]$crontab -l
* 21 * * * /home/oracle/sql/backup/auto_send_perf.sh >> /home/oracle/sql/backup/perf.lst 2>&1

Note: The snapshot report is created from 8:00 AM to 8:00 PM daily and the job of crontab is called at 9:00 AM.

bookmark bookmark bookmark bookmark bookmark bookmark bookmark bookmark bookmark bookmark bookmark bookmark bookmark bookmark bookmark bookmark

Popularity: 26% [?]

Tags:,

Page: 1 | 2 | 3
 

Windows Live Translator

Google