Greetings Monks.

I used to be pretty good with perl, but after a few years of not using it (I don't have time for many projects outside of work, where I'm usually expected to use other languages) I've gotten a bit rusty. I've been trying to revamp our online in/out board using a Perl/Tk script ran through perl2exe, but I've run into a problem. There's a memory leak in the script and I can't figure out what I did wrong or if there's a better way to do what I'm trying to do. Can someone help? Here is the script:
#!/usr/bin/perl #perl2exe_include Tk::Pane use Win32::SqlServer; use Tk; use Tk::Scrollbar; require Tk::Pane; my $mw=new MainWindow; # Main Window Elements my $titleBanner=$mw->Label(-text=>"*Text changed to protect the innoce +nt*",-font=>"Arial 12 bold")->pack(); my $testbutton=$mw->Button(-command=>\&destframe, -text=>"Refresh")->p +ack(); my $statusFrame=$mw->Scrolled('Frame',-scrollbars=>"oe")->pack(); &destframe; $mw->repeat(10000, \&destframe); # Subroutine to get data from the DB sub GetData{ my $sqlsrv=Win32::SqlServer::sql_init('*Deleted*','*Params*','*For +*','*Security*'); my $batch=<<SQLEND; SELECT firstname, lastname, status FROM *Now I'm just being paranoid* WHERE status is NOT NULL SQLEND my $result=$sqlsrv->sql($batch); return $result } sub destframe{ # StatusFrame # Get the data first my $statusboard=&GetData; #create a loop to populate the status frame my $count=1; foreach my $row (@$statusboard) { my $status="$$row{status}"; if ($status=="1") { $status="In"; }elsif ($status=="0"){ $status="Out"; }else{ $status="Not Set" } my $name=$statusFrame->Label(-text=>"$$row{firstname} $$row{la +stname}")->grid(-row=>"$count", -column=>"1"); my $status=$statusFrame->Label(-text=>"$status")->grid(-row=>" +$count", -column=>"2"); $count++; } } MainLoop;

In reply to Memory Leak by Sisk

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.