even this example fast leak memory and down in core.#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? }
In reply to leak memory in threads by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |