Hi, I have a problem with a memory leak in a perl program that is using the Net::Daemon module.

I copied the Calculator example from the CPAN site and used it as the skeleton for my own program.

I am running my program on a Windows 2000 system and every time a remote system connects to it I can see the memory for the perl process increase about 4K. It acts like maybe the thread that gets started to access the new connection doesn’t get cleaned up for some reason.

What the program does is sit on one of my build machines and allows me to collect information from the machine to get status about builds and to allow me to start a build remotely.

I was wondering if I am doing something wrong since this is my first server/client program.

Time: [Mon Dec 8 16:10:32 2008] Mon Dec 8 16:10:32 2008 : Starti +ng Monitor client Parent session Time: [Mon Dec 8 16:10:51 2008] Client: Recieved input of <sx_4.9. +2.0> <Get_Status> Time: [Mon Dec 8 16:10:51 2008] Check_Build branch:<sx_4.9.2.0> c +:\buildscripts\sx_4.9.2.0\inProgress Time: [Mon Dec 8 16:11:08 2008] Get_Status: SX_4.9.2.0.124.000 5,2 +30,792,704 Passed Thu Dec 4 21:35:48 2008 Time: [Mon Dec 8 16:11:08 2008] Client: Closing Socket and shuttin +g down? Time: [Mon Dec 8 16:11:08 2008] Client: Recieved input of <sx_4.9. +1.0> <Get_Status> Time: [Mon Dec 8 16:11:08 2008] Check_Build branch:<sx_4.9.1.0> c +:\buildscripts\sx_4.9.1.0\inProgress Time: [Mon Dec 8 16:11:19 2008] Get_Status: SX_4.9.1.0.097.000 5,2 +30,268,416 Passed Fri Nov 7 14:28:47 2008 Time: [Mon Dec 8 16:11:19 2008] Client: Closing Socket and shuttin +g down? Time: [Mon Dec 8 16:12:19 2008] Client: Recieved input of <sx_4.9. +2.0> <Get_Status> Time: [Mon Dec 8 16:12:19 2008] Check_Build branch:<sx_4.9.2.0> c +:\buildscripts\sx_4.9.2.0\inProgress Time: [Mon Dec 8 16:12:31 2008] Get_Status: SX_4.9.2.0.124.000 5,2 +18,193,408 Passed Thu Dec 4 21:35:48 2008 Time: [Mon Dec 8 16:12:31 2008] Client: Closing Socket and shuttin +g down? Time: [Mon Dec 8 16:12:31 2008] Check_Build branch:<sx_4.9.1.0> c +:\buildscripts\sx_4.9.1.0\inProgress sub Run ($) { my $DEBUG_LOG="c:\\buildscripts\\Monitor\\Client_log.txt"; my($self) = @_; my($line, $sock); my($result); my($rc); my($command); $sock = $self->{'socket'}; if ($self->{'debug'} eq 'ON') { open(DEBUG,">$DEBUG_LOG"); } while(1) { if (!defined($line = $sock->getline())) { if ($sock->error()) { $self->Error("Client connection error %s",$sock->err +or()); } eventLog("Client: Closing Socket and shutting down?"); $sock->close(); return; } $line =~ s/\s+$//; # Remove CRLF ($L_BRANCH,$command)=split(" ",$line); $U_BRANCH=uc($L_BRANCH); eventLog("Client: Recieved input of <$L_BRANCH> <$command>"); SWITCH: { if ( $command eq "Run_Build") { $result=Run_Build(); + last SWITCH; } if ( $command eq "Check_Build") { $result=Check_Build(); + last SWITCH; } if ( $command eq "Get_Status") { $result=Get_Status(); + last SWITCH; } if ( $command eq "Get_Label") { $result=Get_Last_Build_Lab +el(); last SWITCH; } if ( $command eq "Help") { $result=$help_statement; + last SWITCH; } $result="ERROR: Input did not match expected protocol <$comm +and>\n"; } $rc = printf $sock ("%s\n", $result); if (!$rc) { $self->Error("Client connection error %s", $sock->error()); $sock->close(); return; } } } sub new ($$;$) { my($class, $attr, $args) = @_; my($self) = $class->SUPER::new($attr, $args); if ($self->{'parent'}) { # Called via Clone() $self->{'debug'} = $self->{'parent'}->{'debug'}; } else { # Initial call if ($self->{'options'} && $self->{'options'}->{'debug'}) { $self->{'debug'} = $self->{'options'}->{'debug'} } } if (!$self->{'debug'}) { $self->{'debug'} = 'ON'; } $self; }

In reply to memory leak Issue by hdjoe

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.