Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:

I am using the Socket module to read and write messages over a network. When sending and recieving small chunks of data, everything functions, but when large chunks of data are requested, the program crashes halfway through recieving the data with message - "Out of memory!". I know that the linux box that I am running this on is NOT out of memory (you can see by running "gtop"). I have tried stepping through the script with the debugger, and the program is always crashing when it tries to pick up the fileHandle with a socket assigned to it, just after it attempts to recieve a large chunk of data. It's as if it has looses the Socket during the large data transmission, then reports Out of Memory! next time I try to get the fileHandle for somthing else. Any suggestions? (using Perl 5.005_03 for i386_linux)

Replies are listed 'Best First'.
Re: Sockets help
by eduardo (Curate) on Jun 23, 2000 at 18:03 UTC
    Hm... are you using Barr's IO::Socket library? At the corporation where I worked we have learned that the IO::Socket library, although excellent for very light socket work, has a horrible time dealing with error conditions. It would appear like error handling was not thoroughly designed into the infrastrucutre, it feels as if it almost was an afterthought. My suggestion for you, as amazingly horrible as this might sound, is attempt to recreate the problem utilizing more low level socket code (in other words, do the work by hand.) If however i've been wrong all along, and you aren't useing the IO::Socket library, then go the other way, and try it :) Maybe you are forgetting something that needed to be done (an fflush here, an fflush there, here an fflush, there an fflush, everywhere an fflush.) Sorry I couldn't be more helpful, but without more of a description of the problem domain, that's as close as we are going to get :)
(jcwren) RE: Sockets help
by jcwren (Prior) on Jun 23, 2000 at 16:18 UTC
    It would be good to know a little bit more about your environment.

    For instance, the ISP that hosts one of my websites limits CGI scripts to running for 10 seconds, and a 8MB footprint. Other servers are known to set even more restrictive limits.

    Of course, if you're doing this as root on your own local box, then it that changes the whole set of parameters. How much data are you trying to pass?

    --Chris