Home > Backend Development > PHP Problem > What to do if php has insufficient memory

What to do if php has insufficient memory

王林
Release: 2023-03-02 15:46:02
Original
4086 people have browsed it

The solution to insufficient php memory is to increase the maximum memory size of php. Specific method: [ini_set('memory_limit', '16M')]. The ini_set() function is used to set the value of php.ini, which takes effect when the function is executed. The setting becomes invalid after the script ends.

What to do if php has insufficient memory

Analysis of the reasons for insufficient memory:

It may be that the php page consumes too much memory. The maximum memory of php is 8M by default.

(Recommended tutorial: php tutorial)

Solution:

Just change the memory size.

Specific method:

Method one:

1. Open the php.ini configuration file;

2. Change the memory_limit from 8M to 16M (or Larger);

3. Just restart the apache service.

Method 2:

Add the following code in the PHP file:

ini_set('memory_limit', '16M');
Copy after login

Function introduction:

PHP ini_set is used to set the value of php.ini. It takes effect when the function is executed. After the script ends, the setting becomes invalid. You can modify the configuration without opening the php.ini file, which is very convenient for virtual spaces.

Function format:

string ini_set(string $varname, string $newvalue)
Copy after login

Note: For the normal use of other resources in the system, please do not set the value of memory_limit too large.

The above is the detailed content of What to do if php has insufficient memory. For more information, please follow other related articles on the PHP Chinese website!

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