How PHP modifies memory_limit memory limit

Source: Internet
Author: User
Today, my new server has installed the php environment, but the error "FatalError: Allowedmemorysizeofxxxxxxbytesexhausted" is prompted at runtime, which is due to insufficient memory.

Today, I have installed the php environment on my new server, but the Error "Fatal Error: Allowed memory size of xxxxxx bytes exhausted" is displayed at runtime. the memory is insufficient, next I will introduce several solutions to these problems.

Method 1: edit php. ini in php. ini.

Find the "memory_limit" item. if not, you can add this parameter at the end of the file. Below are some setting examples: memory_limit = 128 M; you can change m to any value you want to set.

Method 2:. htaccess

Note: This method takes effect only when php is executed using the Apache Module. Find ". htaccess file. if not, you can create one by yourself and put the following configuration into it:

Php_value memory_limit 128 M; you can change M to any value you want to set.

Method 3: modify the php memory settings at runtime

Add the following command line to your php code: ini_set ('memory _ limit ', '128m ');

Tip:If you use php5.2.17, the above method may not work for you. this official bug cannot solve some problems, and we can only reinstall the php environment, such as php5.4.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.