Re: memory allocation problems with fgets
| From: | Roman Neuhauser | Date: | Tue, 16 Jan 2007 00:27:19 +0000 |
| Subject: | Re: memory allocation problems with fgets | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-247122@lists.php.net to get a copy of this message | ||
# maurizio.molina@dante.org.uk / 2007-01-15 16:43:50 +0000:
> 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.
What makes you sure that loop is the culprit? Does the script still
work if you set memory_limit to -1 right before the loop, and back to
its old value right after it?
--
How many Vietnam vets does it take to screw in a light bulb?
You don't know, man. You don't KNOW.
Cause you weren't THERE. http://bash.org/?255991