in reply to perl 5.12.3 + threads + memory leak

I'm not surprised at all looking at your code. Re-post when you've made it strict-safe and I'll take a look.


Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
"Science is about questioning the status quo. Questioning authority".
In the absence of evidence, opinion is indistinguishable from prejudice.
  • Comment on Re: perl 5.12.3 + threads + memory leak

Replies are listed 'Best First'.
Re^2: perl 5.12.3 + threads + memory leak
by kamenpetrov (Novice) on Feb 14, 2011 at 15:25 UTC
    That should be strict-safe and still leaking memory:

    #!/usr/local/bin/perl use strict; my ($page,$total) = ('http://www.sics.se/~joe/bluetail/vol1/v1_oo.html +',0); use threads; for (my $i=0;$i<10;$i++) { threads->create({'stack_size' => 32*4096},\ +&sub1, $page, $i); } while ($total < 10) { foreach my $thread_join (threads->list(threads::joinable)) { $total++; my $res = $thread_join->join(); print "Thread done\n"; } } print "Press ENTER to finish"; my $ok = <STDIN>; sub sub1() { my ($url,$i, $content) = @_; require LWP::UserAgent; my $ua = LWP::UserAgent->new; my $response = $ua->get($url); print "\t[$i]FETCHED $url\n"; if ($response->is_success) { $content = $response->decoded_con +tent; } return; }

    Thanks in advance.

      If this leaks on your system (it doesn't on mine) then zwon has called it below:

      perl -Mthreads -e'async{ async{ 1;}->join }->join while 1'

      Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
      "Science is about questioning the status quo. Questioning authority".
      In the absence of evidence, opinion is indistinguishable from prejudice.