Fatal error: Allowed memory size of 134217728 bytes exhausted (tried to allocate 11 bytes) in
file_get_contents(BIG_FILE);
Fatal error: Allowed memory size of 134217728 bytes exhausted (tried to allocate 11 bytes) in
should I change a variable in php.ini
PHP
Last Comment
rgb192
8/22/2022 - Mon
Dave Baldwin
That depends. How big a file are you trying to get? Note that it has to fit in memory along with all the PHP code.
rgb192
ASKER
46,000 kb
I am reading the skype sql file
Dave Baldwin
Change 'memory_limit' in 'php.ini' from 128M to 256M. You are probably reading the file in Ok but processing such a large file will take more memory. You may have to restart Apache.
The line numbers matter here. What line of the script fails? What is the PHP code on that line?
I am fairly certain that the 46 megabyte file is getting processed somehow and in PHP standard (not OOP) notation, PHP often makes copies of the variables to pass the copies to the functions. PHP arrays are also amazingly large when compared to the string data. You might want to get familiar with memory_get_usage()
rgb192
ASKER
Sorry about not providing code.
Fatal error: Allowed memory size of 134217728 bytes exhausted (tried to allocate 11 bytes) in C:\wamp\www\test\readingsql.php on line 3
note: sql-file has no extension.
Code runs on nusphere phpED ide, but not wamp
But that aside, the cause of the failure is data proliferation caused by internal designs in PHP. Instead of that, I recommend that you try this:
$str = file_get_contents($filename);
I expect that if your data set is 46 megabytes you will be able to get it into a string variable.
Also, I would recommend that you revisit this question. I am sure that @JulianH meant well, but that is a technically incompetent solution and you should be using the regular expression on a string variable instead of trying to use strpos() on elements of an array. There is sometimes a bit of "deep background" thinking involved in application design, and when I saw the sample data in that question, I knew instantly that any design using an array would run out of memory very, very soon.