1

I have implemented all things as below

PHP Fatal error: Out of memory (allocated 1707606016) (tried to allocate 426680697 bytes)

Implemented all solutions which mentioned in above post

Still it's giving same error

Fatal error: Out of memory (allocated 764801024) (tried to allocate 20480 bytes)

I also tried setting memory_limit to -1 & even in .htaccess as well.

Using https://www.digitalocean.com/

Below is the code

set_time_limit(0);

error_reporting(E_ALL);
ini_set('display_errors', 1);

$file = file_get_contents("test.csv"); // 50MB File on Server

$data = array_map("str_getcsv", preg_split('/\r*\n+|\r+/', $file));

It gives error on last line. In CSV file have html tags which i'm removing by Code.

Able to upload same file in my Local. Problem is on Sever. How to upload 50MB file on Server?

For now i'm using http://erdconcepts.com/dbtoolbox.html CSVSplitter Which is FREE.

Community
  • 1
  • 1
Jackson
  • 922
  • 1
  • 19
  • 49
  • 1
    Increase memory or don't make such memory-hemorrhaging-hugungous variables without releasing previously un-needed references. Or you could chunk out whatever you're parsing. – Blake Oct 20 '16 at 04:10
  • HI @Blake Didn't get u clearly. Can you explain in more detail. Thanks – Jackson Oct 20 '16 at 04:12
  • What part of the comment did you not understand? You didn't provide the code that is erroring out, so it'd all be shots in the dark, or you could follow my previous advice. – Blake Oct 20 '16 at 04:12
  • `such memory-hemorrhaging-hugungous variables without releasing previously un-needed references` this part – Jackson Oct 20 '16 at 04:13
  • you know we cant see you code right? –  Oct 20 '16 at 04:25
  • Updated question Please check – Jackson Oct 20 '16 at 04:26
  • well problem is obvious - dont reed 50mb file in to memory –  Oct 20 '16 at 04:31
  • Possible duplicate of [Allowed memory size of 33554432 bytes exhausted (tried to allocate 43148176 bytes) in php](http://stackoverflow.com/questions/415801/allowed-memory-size-of-33554432-bytes-exhausted-tried-to-allocate-43148176-byte) – Akshay Khetrapal Oct 20 '16 at 05:42
  • But i need to upload `50MB` file. Commented `ini_set('memory_limit', '-1');` or removed as well. Still getting issue on Server – Jackson Oct 20 '16 at 05:53
  • Any updates guys? Please – Jackson Oct 20 '16 at 06:56

0 Answers0