Hi, I have a memory leak and cant find where it is. My script runs on Win32, Activestate perl 633 and I have a csv file that looks like so..

Man;Server;Error;Instance;Instance_Detail;Status;CallNum<P>
The CSV file holds info on the server and what was wrong on the server as well as the call number that is associated with the event. When I have another similar event I check to see if a call already exists in the CSV file.

The code I use is this.. it works but I loose about 4k for every time I query this CSV file...

$call_num = &Check_For_Call($Man,$Server,$Error,$Instance_Detail);

sub Check_For_Call { My subroutine looks like so

my ($Man,$Server,$Error,$Instance_Detail) = @_; $num = (); $dbh = DBI->connect(qq{DBI:CSV:f_dir=$xcall_path}) or die &Debug_L +og("\nDEBUG - Problems Connecting to CSV File\n"); $dbh->{'csv_tables'}->{'Exist'} = { 'file' => 'ExistCalls', 'sep_char' => ';', 'eol' => "\n"}; my($query) = "SELECT CallNum FROM Exist where Man like '$Man' and +Server like '$Server' and Error like '$Error' and Instance_Detail lik +e '$Instance_Detail'"; #&Debug_Log("SELECT CallNum FROM Exist where Man like '$Man' and S +erver like '$Server' and Error like '$Error' and Instance_Detail like + '$Instance_Detail'\n"); my($sth) = $dbh->prepare($query) or &Debug_Log("\nDEBUG - Prob +lems Preparing the SQL Statement in Check_for_Call\n"); $num = $sth->execute() or &Debug_Log("\nDEBUG - Problems Execu +ting the SQL Statement in Check_for_Call\n"); if (defined $num) { chomp($num); $sth->finish(); $dbh->disconnect(); return ($num); } else { #No Call Number Defined $sth->finish(); $dbh->disconnect(); return (2); } $sth->finish(); $dbh->disconnect(); return(1); }

If I have a return of "1" then I know that there is no call that currently exists for the event that I received. If I get a return of "2" then I know that I have received this event before but have not received the corresponding call number yet. other wise I want to return the "call number" in the CSV file.

I do get all the correct responses from the code above I just can't let the script run without stopping and starting it every so often due to the memory leak.

Any Ideas..?

Many Thanks.

-----
Of all the things I've lost in my life, its my mind I miss the most.


In reply to DBD::CSV Memory Leak by AcidHawk

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.