Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?
 
PerlMonks  

Re: IO::Select Memory Hog?

by kjherron (Pilgrim)
on Aug 23, 2001 at 23:56 UTC ( [id://107494]=note: print w/replies, xml ) Need Help??


in reply to IO::Select Memory Hog?

s/memory/cpu/ noted...

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:

while(1) { foreach $client ($select->can_read(0)) { dostuff } }
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.

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
    Yeah, unfortunately I need it not to block. Once it gets a client connection it has to spit out data as fast as possible. I can't fork and I can't use threads so I guess I'm entirely screwed.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://107494]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others sharing their wisdom with the Monastery: (7)
As of 2024-04-24 09:55 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found