I have the following code:
<?php
$FILE="giant-data-barf.txt";
$fp = fopen($FILE,'r');
$data = fread($fp, filesize($FILE));
fclose($fp);
$data_arr = json_decode($data);
var_dump($data_arr);
?>
The giant-data-barf.txt file, as its name implies, is a huge file (itβs 5.4mb right now, but can increase up to several GB).
When I execute this script, I get the following error:
Fatal error: Allowed memory size of 134217728 bytes exhausted (tried to allocate 71 bytes) in ........./data.php on line 12
I reviewed possible solutions and saw the following:
ini_set('memory_limit','16M');
and my question is, is there a limit to how big I have to set my memory? Or is there a better way to solve this problem?
source
share