Hi Monks !
I need your suggestion on something I can't figure out.
So, I am running:
/usr/local/bin/perl -v
This is perl 5, version 12, subversion 3 (v5.12.3) built for i686-linux
and I have the following simple script:
#!/usr/local/bin/perl
use LWP::UserAgent;
my $ua = LWP::UserAgent->new;
$ua->timeout(2);
$page = 'http://www.sics.se/~joe/bluetail/vol1/v1_oo.html';
use threads;
$total = 0;
while (1==1) {
if ($total < 50) {
$total++;
my $threadname = 'thr'.$total;
$$threadname = threads->create(\&sub1, $page);
}
foreach my $thread_join (threads->list(threads::joinable)) {
my $res = $thread_join->join();
print "RES:[$res]\n";
}
sleep(1);
}
sub sub1() {
my ($url) = @_;
print "\t FETCHED $url\n";
my $response = $ua->get($url);
if ($response->is_success) { $content = $response->decoded_con
+tent; }
else { $content = ''; }
return length($content);
}
So.. that thing is leaking memory :(
The script is really simple, but not that simple for me to figure out the cause for the leak.
What I suspect is.. eventually IO::Socket does it...
Any suggestions are welcome.
Thank you in advance.
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: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.