memory allocation problems with fgets

From: Date: Mon, 15 Jan 2007 16:43:50 +0000
Subject: memory allocation problems with fgets
Groups: php.general 
Request: Send a blank email to php-general+get-247103@lists.php.net to get a copy of this message
Hi, I have a script parsing the lines of a (rather large) file: while (!feof($outPluginfh)) { $outPlugin = fgets ($outPluginfh,1024); # process $outPlugin here... .... } Now, with large files I was running into an memory allocation error (after 16MB of allocation..). It looks that php is allocating space for each fgets call, an not releasing it, in spite of the return value being always assigned to the same variable. I red in other posts that for removing this 16MB limit I can simply put the statement ini_set("memory_limit",-1); at the beginning, and in fact this line does the job. However, I'm not happy because I lost control of how much memeory php is allcating on my system, and I fear that with multiple users triggering this script I'll sooner or later run into (worse) problems. Is there any other more controllable way to do? Thanks, Maurizio Molina

« previous php.general (#247103) next »