ktsirig Posted November 13, 2009 Share Posted November 13, 2009 Hello, I have a php page that the user enters some data in a textarea, and then this data is fed into a command line program. When the execution of the command line programm finishes, the results are stored in an output file that is created. The "results" php page then reads this file and the user views the results. My problem is that sometimes (depending on the amount of data inserted and, subsequently the size of the output file created by the command-line programm), the php results page crushes, outputting error like: Fatal error: Allowed memory size of 16777216 bytes exhausted (tried to allocate 846269 bytes) in /results.php on line 125 In this line of the script, I read the whole file into a string and then separate each result chunk by a separator (//) that the command line programm creates: $res_handle= fopen($output_file, "r"); $results = fread($res_handle, filesize($output_file)); fclose($res_handle); $separated_entries = explode ("//", $results); Then, foreach chunk, I output the results to the user. Is there something that I must configure in php so that it won't have memory problems? Or another way to slurp the total output file without exhausting the memory? thank you! Quote Link to comment https://forums.phpfreaks.com/topic/181372-avoid-php-hanging-page/ Share on other sites More sharing options...
Daniel0 Posted November 13, 2009 Share Posted November 13, 2009 You can increase the maximum allowed memory usage in php.ini. It might be smarter working with chunks of data at a time instead of loading everything immediately. Quote Link to comment https://forums.phpfreaks.com/topic/181372-avoid-php-hanging-page/#findComment-956753 Share on other sites More sharing options...
Schlo_50 Posted November 13, 2009 Share Posted November 13, 2009 I believe to solve this you'd have to change the php config file's memory allowance (php.ini). Although some hosts do not allow you to modify the php.ini file. Quote Link to comment https://forums.phpfreaks.com/topic/181372-avoid-php-hanging-page/#findComment-956755 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.