Home  >  Article  >  Backend Development  >  Quick solution to insufficient php memory_PHP tutorial

Quick solution to insufficient php memory_PHP tutorial

WBOY
WBOYOriginal
2016-07-13 10:25:48847browse

Sometimes when we run the php program,

will appear

Allowed memory size of 8388608 bytes exhausted (tried to allocate 1298358 bytes)

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), and restart the apache service

2. Add ini_set('memory_limit','**M') in the PHP file; 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 (provided that the directory supports .htaccess) and add a sentence in the document: php_value memory_limit 16M (or greater)

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/824931.htmlTechArticleSometimes when we run the php program, Allowed memory size of 8388608 bytes exhausted (tried to allocate 1298358 bytes ) The reason for this error: Make sure it is not caused by a program...
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