I have a PHP script which reads data from a file and parse the strings into array like this:
$handle = fopen('syndata.txt', 'r');
while (!feof($handle)) {
$data = fgets($handle);
$convert = explode(",", $data);
array_push($arrayStr, $convert);
}
fclose($handle);
Where syndata.dat
is a file of size 2.5 GB. When I run the script, it takes a few minutes to run and after that goves fatal error of "Out of Memory" on line $data = file_get_contents("syndata.dat");
.
I have tried everything increasing memory limit in php.ini file. Currently, memory_limiy parameter is set to the value -1 which means that unlimited memory. Still it gives fatal error. "Fatal error: Out of memory (allocated 520093696)(tried to allocate 519569408)"
Please help me resolving the issue.