Re: memory allocation problems with fgets

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



# maurizio.molina@xxxxxxxxxxxx / 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

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux