Today I changed a server and ran php for a long time, and I found the Fatal error: Allowed memory size of 33554432 bytes exhausted prompt. Let me introduce to you how to solve this problem.
Solution
Method 1 (recommended), modify the setting value of memory_limit in php.ini from 8M to 120M: memory_limit = 120M
Method 2: Add a line to the top PHP Script: ini_set("memory_limit", "120M");
Whether I am using a wordpress blog, my solution is a little different, and I will share it below.
1. Network method, it is said that this is suitable for versions before 3.0. Edit the wp-config.php file and add
The code is as follows
代码如下 |
复制代码 |
define(‘WP_MEMORY_LIMIT’, ’64M’);
|
|
Copy code
|
define(‘WP_MEMORY_LIMIT’, ’64M’);
代码如下 |
复制代码 |
global $blog_id;
// set memory limits
if ( !defined('WP_MEMORY_LIMIT') ) {
if( is_multisite() ) {
define('WP_MEMORY_LIMIT', '64M');
} else {
define('WP_MEMORY_LIMIT', '32M');
}
}
|
| 64M can be higher. Can be 96M, 128M.
2. For versions after 3.0, if you need to modify the source file, you don’t have to change it if you mind. Find the following code in the default-constants.php file in the wp-includes directory
The code is as follows
|
Copy code
global $blog_id;
// set memory limits
if ( !defined('WP_MEMORY_LIMIT') ) {
if( is_multisite() ) {
define('WP_MEMORY_LIMIT', '64M');
} else {
define('WP_MEMORY_LIMIT', '32M');
}
}
http://www.bkjia.com/PHPjc/633193.htmlwww.bkjia.comtruehttp: //www.bkjia.com/PHPjc/633193.htmlTechArticleToday I changed a server and ran php for a long time, and I found a Fatal error: Allowed memory size of 33554432 bytes exhausted prompt. , let me introduce to you the solution to this problem. Solution...
|
|