Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

DBI Leaking Memory

DBI Leaking Memory

DBI Leaking Memory

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;


RE: DBI Leaking Memory

does it still leak if you work through the result set?

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.

RE: DBI Leaking Memory

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.

RE: DBI Leaking Memory

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.

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.

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close