Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:

Hi monks. Can anybody help me?
I have programm with thread (look there little piece of it)
#packages what uses use HTTP::Daemon; use LWP::UserAgent; use URI::Escape; use threads; use threads::shared; #packages what uses $DEBUG = 1; share(%LC); share(%Last); # Create socket for ICP-server $ICP_PORT=3130; $SOCKADDR = 'S n a4 x8'; socket(S, 2, 2, 17) || socket(S, 2, 1, 17) || die "Couldn't get ICP-so +cket: $!"; $us = pack($SOCKADDR, 2, $ICP_PORT, pack("C4", 0,0,0,0)); bind(S, $us) || die "Couldn't bind ICP-socket: $!"; # Create ICP-log file if (! -e "icp_access.log") { open(ICP,">icp_access.log") || die "cant create icp_access.log"; close(ICP); } # Create ICP threads $ICP_Thread = threads->new(\&ICPserver); threads->yield(); threads->list(); while(1){} ###################################################################### #ICP thread ###################################################################### sub ICPserver { my $i = 0 ; while(1) { # $theiraddr = recv(S, $ICP_request, 1024, 0); $i++; $ICP_request ="request $i"; if ($DEBUG) {print "ICP request: $ICP_request\n";} $ICP_Search = threads->new(\&ICPrequest, $ICP_request ); $ICP_Search->detach(); # only wait for($z=0;$z<10000;$z++){$t=$z;} } } sub ICPrequest{ my $ICP_request = shift; $ICP_request =~ /request (\d+)/; if ($DEBUG) {print "result for $1\n";} if ($DEBUG) {print "thread is ended\n";} # MUST CLEAN UP? }
even this example fast leak memory and down in core.
may be problem in my system?
this tested on FreeBSD 4.7 and Perl 5.8.0 Perl 5.8.1
or problem in packages
Can somebody explain it? What i doing wrong?

Replies are listed 'Best First'.
Re: leak memory in threads
by liz (Monsignor) on Oct 28, 2003 at 19:08 UTC
      I install 5.8.2
      problem not solved
      example is down again.
      may be it is only on FreeBSD?