Home  >  Article  >  Backend Development  >  How to solve the problem of insufficient memory in php

How to solve the problem of insufficient memory in php

藏色散人
藏色散人Original
2020-07-08 09:27:473726browse

Solution to insufficient php memory: 1. Modify "php.ini" to change "memory_limit" from 8M to 16M, and restart the apache service; 2. Add "ini_set('memory_limit', '**M');"; 3. Modify htaccess.

How to solve the problem of insufficient memory in php

Solution to insufficient php memory

Sometimes when we run the php program again,

Allowed memory size of 8388608 bytes exhausted (tried to allocate 1298358 bytes)
# will appear ##The reason for this error: After making sure that it is not caused by the program (such as an infinite loop), it is because the maximum memory consumed by the PHP page is 8M by default (can be seen in the PHP ini file),

If the file is too large or the image is too large, the above error will occur when reading.

Solution:

1. Modify php.ini to change memory_limit from 8M to 16M (or larger), restart the apache service

2. Add in the PHP file ini_set('memory_limit','**M'); Note: For the normal use of other resources of the system, please do not set the memory_limit too large, where -1 means no limit

3. Modify the .htaccess document (The premise is that the directory supports .htaccess) Add a new sentence in the document: php_value memory_limit 16M (or greater)

For more related knowledge, please visit

PHP Chinese website!

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

Statement:
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