in reply to IO::Select Memory Hog?
The loop you show looks fine, but you understand that can_read(0) doesn't block? It returns immediately, whether any handles are ready or not. If the surrounding code is essentially:
then you're going to keep calling can_read() just as fast as you can, rather than truly blocking until a file handle becomes ready.while(1) { foreach $client ($select->can_read(0)) { dostuff } }
If you want can_read() to block as long as necessary, then you shouldn't pass a timeout argument. IF you need can_read() to return every so often, then you should pass some timeout other than 0. Only use 0 for the timeout if you don't want the call to block.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: IO::Select Memory Hog?
by rapier1 (Novice) on Aug 24, 2001 at 21:31 UTC |