Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

DBI Leaking Memory

Status
Not open for further replies.

tbahr

IS-IT--Management
Jan 12, 2001
6
0
0
US
Running Windows NT 4.0, using MS SQL 7.0 and Latest Perl build from ActiveState and DBI 1.14 and DBD-ODBC.

Any ideas why the following lines leak memory in the sqlserver.exe process. Around 4k each time the script runs. It doesn't seem to matter what SQL query I issue.

use strict;
use DBI;

print "Content-Type: text/html\n\n";

my $Conn;
my $RS;

$Conn = DBI->connect("dbi:ODBC:vitafree", "sa", "banff",{PrintError=>0,RaiseError=>0});

$RS = $Conn->prepare("select count(*) from session") || die $DBI::errstr;
$RS->execute() || die $DBI::errstr;
$RS->finish;

$Conn->disconnect();
 
does it still leak if you work through the result set? Mike
michael.j.lacey@ntlworld.com
Email welcome if you're in a hurry or something -- but post in tek-tips as well please, and I will post my reply here as well.
 
Even if I do an update or deletion, it still seems to leak.
I added a $RS->fetchrow(); between the execute and finish and it seems to slow down the memory leak. It now seems like every 4 iteration it leaks instead of each time.

Is RS->finish; a must for each and every query. I have a wrapper around the prepare and execute call and some times do not care about the $RS handle it returns on deletions and updates, so I do not call RS->finish unless I work through the result set. Should I go through and call RS finish for all calls. Thanks for your help.
 
I always call finish on statement handles, just to make me feel good; it bothers me not to explcitly tidy up.

I would post your leak problem to the DBI users list. I know that Tim Bunce is on that list and he's the guy who would be able t fix any leak you have found.

Before you do that though - make sure you have uptodate versions of the DBI and DBD::ODBC. I would make sure you include all relevant version info (as you've done in your post above) when you post to DBI-Users -- people *have* been know to be a tad impatient with partial info. <smile>

If you don't know where DBI-Users is drop me an email and I'll send you the URL. Mike
michael.j.lacey@ntlworld.com
Email welcome if you're in a hurry or something -- but post in tek-tips as well please, and I will post my reply here as well.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top