Hi Monks,

There seems to be a memory leak in DBD::Firebird (or one of its dependencies). Every call after the first one seems to leak 1 Scalar Value (SV).

Here is a code sample which will create a table, query it 6 times and drop it.

I have upgraded to the latest version of DBD::Firebird and I'm on Kubuntu 14.04 lts with Firebird 2.5.

Update: Thanks to sierpinski for pointing out that there was no question here. Has anyone seen this before? I imagine it might be the driver, but I guess it could be Firebird too. I'd like to see where the problem is. If it's fixable, we should fix it, otherwise I'll need to workaround it. Suggestions welcome.

Here is the code, you just need to create an empty database file (I use Flamerobin for this) and modify the dsn in the code appropriately.

Thanks for your help

Code follows

Regards

Steve

#! /usr/bin/perl package main; use strict; use warnings; use DBI; use Devel::Leak; my $handle; my $count_start; my $count_stop; my $gl_dbh; # Just do this 5 times to make sure there is no contribution to $h +andle count from Devel::Leak for (1..10){ print "Handle init: ", Devel::Leak::NoteSV($Launch::handle),"\n"; } my $loc_dsn = <<DSN; dbi:Firebird:dbname=/home/image/Documents/Endoscopia/DB/endoNew.fdb; ib_dialect=3; DSN $Launch::gl_dbh=DBI->connect($loc_dsn,"SYSDBA","masterkey", { PrintError => 1, # Report errors via warn RaiseError => 1 # Report errors via Die } ) or die; my @loc_sql_string =(); $loc_sql_string[0]="CREATE TABLE TBL_TEST_LEAK ( ATTR_RECORD_ID_T +XT VARCHAR(10) NOT NULL, ATT_RECORD_NAME_TXT VARCHAR(255), CONSTRAINT + PK_TBL_TEST_LEAK PRIMARY KEY (ATTR_RECORD_ID_TXT) ); "; $loc_sql_string[1]="GRANT DELETE, INSERT, REFERENCES, SELECT, UPDA +TE ON TBL_TEST_LEAK TO SYSDBA WITH GRANT OPTION"; $loc_sql_string[2]="INSERT INTO TBL_TEST_LEAK (ATTR_RECORD_ID_TXT, + ATT_RECORD_NAME_TXT) VALUES ('206', 'Delay Test 1' )"; $loc_sql_string[3]="select ATT_RECORD_NAME_TXT from TBL_TEST_LEAK; + "; $loc_sql_string[4]= $loc_sql_string[3]; + $loc_sql_string[5]= $loc_sql_string[3]; + $loc_sql_string[6]= $loc_sql_string[3]; + $loc_sql_string[7]= $loc_sql_string[3]; + $loc_sql_string[8]= $loc_sql_string[3]; + $loc_sql_string[9]="drop table TBL_TEST_LEAK; "; + for (my $i=0;$i<=9;$i++){ $count_start=Devel::Leak::NoteSV($Launch::handle); print "DBD start: ", $count_start,"\n"; print $loc_sql_string[$i], "\n"; dbd_select($loc_sql_string[$i]); # You can use #$count_stop=Devel::Leak::CheckSV($Launch::handle); $count_stop=Devel::Leak::NoteSV($Launch::handle); print "Handle stop: ", $count_stop,"\n"; print "Count difference: ", $count_stop-$count_start,"\n"; } $Launch::gl_dbh->disconnect; sub dbd_select{ my $loc_sql_string=shift; my $loc_sth=$Launch::gl_dbh->prepare($loc_sql_string) or die; $loc_sth->execute() or die; $loc_sth->finish(); return; } 1;

In reply to Memory leaks in DBD::Firebird by Steve_BZ

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.