The following error is reported when executing the PHP program
Fatal error:allowed memory size of 134217728 bytes exhausted (tried to allocate) bytes nn.php on line 18
The first method: not recommended
Modify php config file php.ini, Change the value of memory_limit, but do not recommend this, because no matter how big the changes, It is possible to report this error because you do not know How much memory is required to run this PHP code
The second method: recommended
It is generally a matter of assigning too much content to a variable at once, such as copying the contents of a 1GB mysql table to a variable at once, which will certainly result in running memory exceeding the size limit in the profile.
Workaround
First step: First calculate how many records in this table $sql= ' SELECT COUNT (*) as NUM from table_name '; $Num _res=sql_query ($sql);// Step two: Use the For loop and limit limits how many items to fetch at once, such as fetching 100 records at a time $num= $Num _res[0][' Num '];for ($i =0; $i < $Num; $i +=100) {$a = "select * FROM table_name limit $i, 100 ";//Specific other actions}
Note: Sql_query () is my self-determined method, we mainly look at the idea
This article is from the "Technology" blog, so be sure to keep this source http://hywds.blog.51cto.com/13158032/1958039
Error allowed memory size of 134217728 bytes exhausted (tried to allocate) when executing PHP program