in reply to Multithreaded memory usage

Forget using Perl's Windows fork emulation. It leaks like a sieve.

See how you get on with this. On my system it settles down to a steady state memory usage after a few cycles:

#! perl -sw use 5.010; use strict; use threads ( stack_size => 4096 ); while( 1 ) { async( \&get_data_and_go )->detach; sleep 5; ## Go get every 5 seconds } sub get_data_and_go { my $tid = threads->tid; require LWP::Simple; ## Requiring prevent CLONE leaks. ##does some webpage stuff and exits my $bytes= length( LWP::Simple::get( 'http://www.yahoo.com' ) ); say "$tid : Got $bytes"; sleep rand 10; ## Simulated variable processing time say "$tid : done"; return 0; };

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.
"Too many [] have been sedated by an oppressive environment of political correctness and risk aversion."

Replies are listed 'Best First'.
Re^2: Multithreaded memory usage
by bingohighway (Acolyte) on Apr 21, 2009 at 20:20 UTC
    Superb :-) Did the trick. No memory leaks and seems to be less CPU intensive.

    Cheers!