perlquestion
Krambambuli
Dear Perlmonkers,<br><br>
I'm fighting a memory leak with DBI/DBD::Oracle which I do not really know how to tackle. I tracked it down to a simple code sequence like
<code>
{
my $sth;
sub _read_from_db {
my ($array_ref) = @_;
if (not defined $sth) {
$sql = qq/ ... /;
$sth = $dbh->prepare( $sql );
}
$sth->bind_param( ... );
$sth->execute();
@$array_ref = $sth->fetchrow_array();
}
}
</code>
The problem is that the script using the code steadily grows over runtime, always in 4 byte increments; the increment happens not with each iteration, but (apparently random) after 5, 6 or 7 iterations. I also found that it's the call to $sth->execute() that causes the increase in memory footprint.<br><br>
The very same code runs OK on another (White Box Enterprise Linux release 3.0) system.<br><br>
On the problematic system CentOS release 5 (Final) is installed.<br><br>
I've tried to upgrade DBI, DBD::Oracle and Perl to the latest versions; no improvement. I downgraded DBI, DBD::Oracle and Perl with a few version numbers - same behavior.<br><br>
But when I then compiled Perl without threads - SUCCESS! - problem gone, code worked OK.<br><br>
No joy however: I specifically want and need to use threads once the script stops to leak memory.<br><br>
It seems clear that it is a OS-specific problem; I'm just a bit lost for now not knowing really which direction to head.<br><br>
I'm pretty sure that some of the monastery veterans have fought such wars before; so what would others do in this situation ?<br><br>
Many thanks in advance.<br><br>
<b>Final update:</b> it turned out to be not at all CentOS specific, not even a Perl or thread problem, but just an Oracle bug. I was able to overcome the problem without re-installing anything on server-side Oracle after (correctly - that was rather harder than expected!) rebuilding DBD::Oracle with Oracle Instant Client 10.2.0.3 (might work with other versions as well, it's just the version I happened to use). It was [gsiems]'s suggestion that helped me find the solution. Thanks to all those who lent a helpful hand!<br><br>
<readmore>
<b>Update:</b> after further googling and looking through documentation, it seems that it is more an Oracle 9iR2 problem (which is what I use):<br><br>
<a href="http://search.cpan.org/src/PYTHIAN/DBD-Oracle-1.22/README.macosx.txt">Same problem on Mac OS</a><br>
< a href="http://lists.open-bio.org/pipermail/biosql-l/2005-June/000869.html">Same problem on Linux Suse 9.0</a><br><br>
As I won't be able to change the installed Oracle at least for some time, I guess I won't have a quick answer here.<br><br>
<b>Update 2:</b> Seems that HP-UX 11 has seen this <a href="http://lists.open-bio.org/pipermail/biosql-l/2005-June/000869.html">too</a>. But this last link also might bring the long awaited light on the matter:<br><br>
<code>
There is a memory leak from the Oracle Client Interface on HP-UX 11
* Scenario: A memory leak has been observed from the Oracle Client Interface (OCI)
when using Oracle 9i Release 2 (9.2.0.1) on HP-UX 11.
* Solution: This problem has been fixed by Oracle and the fix is available by upgrading
to Oracle 9i Release 2 Database Server Patch Set 2 for HP9000 Series HP-UX (64-bit).
This has the Oracle patch number of 2761332.
To install the above Oracle patch, you might need to upgrade your Oracle installer (OUI)
to version 2.2.0.18.0 first. The Oracle patch number for this upgrade is 2878462.
</code>
<br> Now, as it seems that the Oracle I deal with hasn't the released patches installed, it looks like there is nothing more to do or try before getting those patches applied.<br><br>
Thanks and sorry for the noise ;)
</readmore>
<!-- Node text goes above. Div tags should contain sig only -->
<div class="pmsig"><div class="pmsig-600591">
<br>Krambambuli<br>
</div></div>