file_get_contents crash, if file is bigger than memory_limit

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

 



I really dont know, if this is the right board for this... but i think, i
have to write it down.

Please throw an error, if file_get_contents cant read a file because
memory_limit overflow!

I´ve programmed a tool parsing checksums from large files. Because i have to
manage header-offsets, i have to read the files using file_get_contents.
(This should be the fastest way for this task says the manual... right!)

The problem is, that if the memory_limit in the php.ini is set to 64MB, and
the file read in by file_get_contents is bigger than 64MB, file_get_contents
crashes without an EXCETPION. This crash cant be catched!

I want handle this this way:

try{
    $data = file_get_contents($file);
}
catch (MemoryLimitReachedException $e){
    // try the same using a while loop reading the data! (This works!)
}

Hope, there is a solution for this.

Thank you.
Andreas
http://www.php-gtk.eu/apps/emucontrolcenter

-- 
View this message in context: http://www.nabble.com/file_get_contents-crash%2C-if-file-is-bigger-than-memory_limit-tf3971711.html#a11273559
Sent from the PHP - General mailing list archive at Nabble.com.

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