Home > Backend Development > PHP Tutorial > Fatal error: Allowed memory size of 33554432 bytes exhausted_PHP教程

Fatal error: Allowed memory size of 33554432 bytes exhausted_PHP教程

WBOY
Release: 2016-07-13 10:43:08
Original
1076 people have browsed it

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

64M can be higher. Can be 96M, 128M.
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');
}
}

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'); } }
The second line define(‘WP_MEMORY_LIMIT’, ‘32M’); just change it to 64M.
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...
Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template