[EMAIL PROTECTED] wrote:
>
> Hello,
>
> I have to write a "daemon" in Perl, with the quite simple structure
below :
>
> sub test {
>    while(1) {
>       Oracle database connection;
>       $state = result of a database query;
>
>       if ( $state == 1 ) {
>          call to another function;
>       }
>    }
> }
>
> My function "test" works and makes its job perfectly. Despite this, I
> have pointed a problem out : memory leak. Indeed, the memory size of
> the process grows significantly during its running time, and this is
> not acceptable. I begin to believe writing a such "daemon" in Perl is
> not a good idea, according to articles I read recently. But if someone
> here has an idea, or suggestions to help me, you would spare me a lot
> of time.

Hi Mick

I see no reason why Perl should not be suitable for your purpose, but
the problem must lie in the parts you have generalised, i.e. the
database connection, the query, or the 'other function', as Perl itself
would not leak memory for the remainder of the code. So you need to tell
us more about what you are doing. The first thing that stands out is
that it is wasteful to reconnect to the database for every query. Since
this may also be the source of your memory problem, I suggest rewriting
your function as:

  sub test {

    Oracle_database_connection();

    while(1) {

      my $state = result_of_a_database_query();

      if ( $state == 1 ) {
        another_function();
      }
    }
  }

Of course this may not be possible for some reason, but again we need to
know more about your problem.

HTH,

Rob

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>


Reply via email to