Home > Backend Development > PHP Problem > How to solve php memory overflow

How to solve php memory overflow

王林
Release: 2023-02-23 20:28:01
forward
5605 people have browsed it

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
Copy after login

Method 2:

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

init_set(
"memory_limit"
,
 "128M"
)
;
Copy after login

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!

Related labels:
source:csdn.net
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