memory allocation problems with fgets

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

 



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

-- 
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