Re: Perl function leading to out of memory error

From: Vincent Veyron <vv(dot)lists(at)wanadoo(dot)fr>
To: Jan Strube <js(at)deriva(dot)de>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: Perl function leading to out of memory error
Date: 2013-02-20 15:13:35
Message-ID: 1361373215.2431.11.camel@asus-1001PX.home
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Le mardi 19 février 2013 à 12:05 +0100, Jan Strube a écrit :
> Hi,
>
> we have a Java daemon that´s repeatedly calling a Perl function inside
> our database (version 9.1.8). The function is called about 200 times per
> second. While the Java program is running you can watch the memory usage
> of the postmaster grow continuously until after a few hours we get an
> out of memory error from Postgres. In the log you see a lot of
> "ExprContext..." messages. When the daemon is killed the memory is
> freed.The daemon is using a single database connection during it´s runtime.
>
> You can see the function definition here:
> http://www.deriva.de/tmp/get_comment.txt
>
> Does anyone have an idea what could be wrong here or how I can find out
> where the memory is spend?
>

Not sure, but have you considered closures? I wonder if your use of
%data in $get_value = sub {...} is creating one.

See Merlyn's reply in this thread :

http://www.gossamer-threads.com/lists/modperl/modperl/27667?search_string=closure;#27667

for a way to find out. If so, you can probably do

my $get_value = sub {

my ($data, $table, $cond, $field) = @_;

(where $data is a reference to %data)
...

}

and call it with
my $value = $get_value->(\%data, $1, $2, $3);
instead of
my $value = $get_value->($1, $2, $3);

--
Salutations, Vincent Veyron
http://marica.fr/site/demonstration
Progiciel de gestion des sinistres assurance et des dossiers contentieux pour le service juridique

In response to

Browse pgsql-general by date

  From Date Subject
Next Message ChoonSoo Park 2013-02-20 16:24:17 How to remove an item from integer array type
Previous Message Alexander Law 2013-02-20 12:00:00 Re: BUG #7493: Postmaster messages unreadable in a Windows console