Today, when using a php product, an Allowed memory size of 8388608 bytes exhausted (tried to allocate 46080 bytes) in.... prompt message appeared. After verification, it was because this product did not take user memory into account. Below we Let’s take a look at how to solve this method
It is caused by the parameter memory_limit in php.ini. Because it is not set sufficiently, it causes the above problem. Let’s take a look at several solutions
Method 1, use program to implement
Just add the following command line to your php code
代码如下 | 复制代码 |
ini_set('memory_limit','128M'); |
This requires that your server has not prohibited modification, and ordinary virtual spaces cannot be operated.
Method 2, use .htaccess, this is very feasible.
Add
to your .htaccess代码如下 | 复制代码 |
php_value memory_limit 128M ; |
You can change 128M to any value you want to set.
Method three, this is for friends with server management rights, directly modify the php.ini file.
Find the item "memory_limit". If not, you can add this parameter yourself at the end of the file. Here are some setup examples
代码如下 | 复制代码 |
memory_limit = 128M ; |
You can change 128M to any value you want to set
Just restart apache.
In this way, when I run the product again, the Allowed memory size of 8388608 bytes exhausted (tried to allocate 46080 bytes) in.... mentioned earlier will not appear.