Home  >  Article  >  Backend Development  >  How to solve php memory overflow

How to solve php memory overflow

王林
王林forward
2019-09-09 16:04:445549browse

How to solve php memory overflow

Sometimes when we run the php program, we will find a prompt like Fatal Error: Out of memory . This may be because the program uses a large number of variables and objects, resulting in insufficient allocated memory.

I encountered such an error and couldn't correct it no matter how much I did. Later I checked some information on the Internet, but I modified the memory_limit parameter in the php.ini file, but no matter how I changed it, I still got this error message, especially depressed! Later, I really had no choice, so I asked for help in the QQ group. Someone told me to add "init_set( "memory_limit" , "128M" ); " to my program code. That would be enough, so I gave it a try. It really worked. Now I'm sharing my two methods to solve this problem with you, hoping to help people who encounter similar problems like me.

Method 1:

We can change the default memory_limit parameter from 128M to 256M or larger in the php.ini file:

memory_limit =
 128M

Method 2:

If it is a virtual host, we can add where the program needs to use large memory:

init_set(
"memory_limit"
,
 "128M"
)
;

The above content is for reference only!

Recommended video tutorial: PHP video tutorial

The above is the detailed content of How to solve php memory overflow. For more information, please follow other related articles on the PHP Chinese website!

Statement:
This article is reproduced at:csdn.net. If there is any infringement, please contact admin@php.cn delete

Related articles

See more