0

i would like to ask if someone had the same problem or know any workaroundto fix it.

I have a large file (15MB) full of array values which i find and read them. On xampp the code with preg_match_all works correcly (for large and small files).

on the server Current PHP version: 5.5.9 (2 vcpu 2GB ram) preg_match_all stop execution of the code (if i test with small file it gives correct results).

iMMuNiTy
  • 476
  • 7
  • 20
  • 4
    See http://stackoverflow.com/questions/11315879/php-preg-match-all-100-mb-file, also https://bytes.com/topic/php/answers/7996-preg_match-_all-big-strings – Wiktor Stribiżew Feb 13 '16 at 20:17
  • Do you have the same exact configuration on xampp and on your vps in regard of php.ini and the webserver? Do you have any error on php logs? – peixotorms Feb 13 '16 at 20:18

1 Answers1

1

Try using:

ini_set('memory_limit','1024M');

In the beginning of the script.

Also, if you're calling the script from your browser, print an empty space on that loop to keep your browser alive.

peixotorms
  • 1,246
  • 1
  • 10
  • 21
  • I use preg_match_all so there isn't any loop. For some moment i had put before preg echo the file data and i think that kept the broswer alive and it worked correctly but later (cache maybe?) stop working again – iMMuNiTy Feb 14 '16 at 08:20
  • ini_set('memory_limit','1024M'); has fixed it :) thank you very much! the memory usage will be only for that script running right? (default is defined my ini fule 128M) – iMMuNiTy Feb 14 '16 at 08:44
  • 1
    That 1024M is the memory limit (could be much less than that) and it will be used if needed, only for that running script and while it's running. After that it will be sent to the OS for recycle (meaning you might see it in the buffers, but it will be available for claim from any other software if needed). – peixotorms Feb 14 '16 at 18:21