我讀文件的CSV值:約100MB如何修復致命錯誤:內存(分配)(試圖分配字節)在PHP
//$mypath . '/' . $filename <=> ../abc.csv
$val = file_get_contents($mypath . '/' . $filename);
$escaped = pg_escape_bytea($val);
$model->addFileImport($tmp, $data['email'], $escaped);
我的文件IA。 在php.ini中設置: memory_limit的= 128M
但它仍然顯示在行errort :Fatal error: Allowed memory size of 8388608 bytes exhausted (tried to allocate 133120 bytes) in...
:$val = file_get_contents($mypath . '/' . $filename);
我已經通過固定加ini_set('memory_limit', '-1');
:
//$mypath . '/' . $filename <=> ../abc.csv
ini_set('memory_limit', '-1');
$val = file_get_contents($mypath . '/' . $filename);
$escaped = pg_escape_bytea($val);
$model->addFileImport($tmp, $data['email'], $escaped);
但它顯示錯誤:
Fatal error: Out of memory (allocated 230686720) (tried to allocate 657099991 bytes) in C:\wamp\www\joomlandk\components\com_servicemanager\views\i0701\view.html.php on line 112
在第$escaped = pg_escape_bytea($val);
爲什麼?如何解決這個錯誤?
你耗盡內存,據我可以告訴物理內存。 657099991字節是626.659兆字節。最好的選擇是[使用更大的交換文件](https://www.google.com/search?q=increase+size+of+swap+file)。 –