A quick check shows that each instance of an LWP::UserAgent costs around 6.8MB. Times 20 and that accounts for 136MB of your 200MB before you start adding in threads, stacks, and queues.
Are you sure that using 20 threads is actually achieving gains over (say) just 10?
If you are just fetching lots of pages in parallel, then you might consider LWP::Parallel::UserAgent.
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.
| [reply] |
I switched from LWP to WWW::Curl::Simple, which was sufficiently parallel for my purposes and allowed me to use an unthreaded Perl, which is faster and uses less memory. It may not work for you, but it worked nicely for me.
| [reply] |
As an alternative to using threads (for simple socket communications), consider looking at AnyEvent resp. AnyEvent::HTTP, which will do nonblocking parallel HTTP transfers from a single thread. It's also fairly lightweight, but I haven't looked at its actual memory usage.
| [reply] |