It depends. If you used MFC or STL probably not. If you use ATL maybe. If you eshew the use of template libraries altogether and write directly to the API (Win32 or POSIX) probably.

But the other side of that equation is instead of 15 or 20 lines of code you'll end up writing 100s. And they will be much harder to get right, and much, much harder to debug when they go wrong.

You could also substantially reduce the memory consumption of the Perl program by avoiding LWP and writing your own socket code. For what you are doing it wouldn't be very complex, but it would be much harder to get right.

Or you can strike a compromise and use LWP::Simple and a pool of threads. This version uses ~20MB and < 3% cpu for 10 threads on my system:

#! perl -slw use strict; use threads; use LWP::Simple; use threads::shared; use Thread::Queue; $|++; our $THREADS ||= 10; my $sem :shared; my $Q = new Thread::Queue; sub worker { while( my $url = $Q->dequeue ) { chomp( $url ); { lock $sem; print "fetching $url" } my $content = get "http://$url/"; lock $sem; print "$url : ", $content && $content =~ /ok/ ? 'ack' : 'nack' + } } $Q->enqueue( <> ); $Q->enqueue( (undef) x $THREADS ); my @threads = map threads->create( \&worker ), 1 .. $THREADS; $_->join for @threads __END__ C:\test>715836 urls.txt fetching www.bbc.co.uk fetching news.bbc.co.uk fetching www.ibm.com fetching www.yahoo.com fetching www.microsoft.com fetching www.google.com fetching www.google.co.uk fetching www.google.co.au fetching www.cnn.com fetching www.msnbc.com www.google.co.au : nack fetching www.perl.org www.google.co.uk : ack fetching www.nasa.com www.yahoo.com : nack fetching www.ask.com www.google.com : ack fetching www.itv.com www.perl.org : nack www.nasa.com : nack www.ask.com : nack www.msnbc.com : ack www.itv.com : nack www.ibm.com : ack www.microsoft.com : ack news.bbc.co.uk : ack www.cnn.com : ack www.bbc.co.uk : ack

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."

In reply to Re^5: Parallel::ForkManager (high cpu and a lot of memory) by BrowserUk
in thread Parallel::ForkManager (high cpu and a lot of memory) by marto9

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • 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:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.