> Hi,
> 
> I'm writing a deamon process that has to execute a query at given
> interval.
> I'm using Oracle as the backend..
> 
> But my problem is that when ever the daemon wakes up, it comsumes an
> addition 15 to 20 kb of memory.
> 
> I tried the same with Postgres and I found the size to reamin 
> constant.
> Is there any bug in Orcale DBI .. or is any there any way I 
> can control
> this leakage.
> 
> I'm using Perl version 5.005_03 built for i386-linux and DBI version
> 1.13
> 
> The code sample is below..
> ----------------------------
> #!/usr/bin/perl
> 
> use DBI;
> use POSIX qw(setsid);
> 
> my $sleeptime = 5;                 # sleep time
> while(1) {
>     $ENV{'ORACLE_HOME'} = '/oracle/Ora8iHome';
>     my $data_source="dbi:Oracle:host=127.0.0.1;sid=test";
>     my $dbh=DBI->connect($data_source,"scott","tiger") || die "Can't
> connect: $DBI::errstr\n";
>     my $selsql="select * from employee";
>     my $sthselect=$dbh->prepare($selsql) || die "Can't prepare
> statement: $DBI::errstr\n";

Since the previous 5 lines are constant, why have them in the loop?

>     $sthselect->execute() || die "Can't execute the statement:
> $DBI::errstr\n";
>     $sthselect->finish() || die "Can't finish the statement";
>     undef $sthselect;
>     $dbh->commit;
>     $dbh->disconnect();
>     undef $sleeptime;
>     undef $dbh;
>     undef $data_source;
> 
>     chdir '/' or die "Can't chdir to /: $!";
>     umask 0;
>     open STDIN, '/dev/null'   or die "Can't read /dev/null: $!";
> #  open STDOUT, '>/dev/null' or die "Can't write to /dev/null: $!";
>     open STDERR, '>/dev/null' or die "Can't write to /dev/null: $!";

Again, put these outside the loop.

>     defined(my $pid = fork)   or die "Can't fork: $!";
>     exit if $pid;
>     setsid  or die "Can't start a new session: $!";

Well, are you ever waiting for the children you generate here?  It looks to
me like you're creating an infinite number of children without ever reaping
them. 
Reduce your sleeptime to something like 10 seconds and do repeated 'ps'
commands to double check.

I also have no idea why you're calling it within the loop, instead of near
the top of your program.

>     sleep($sleeptime*60);
> }
> 
> If any body has found the solution, please do let me know.
> 
> Thanks & Regards,
> Avinash K S
 

Reply via email to