Fatal error: Allowed memory size

Source: Internet
Author: User
Tags ini php file server memory

If your ThinkPHP prompts you a Fatal error (Fatal error: Allowed memory size), I don't think it is a good solution to increase the memory available for servers. There is no need for trouble. This is because ThinkPHP has a BUG.

Error message: Fatal error: Allowed memory size of 1073741824 bytes exhausted (tried to allocate 523800 bytes) in/var/www/www.soouj.com/ThinkPHP/Lib/Template/ThinkTemplate.class.php on line 265.

If your error message is the same as mine, tell you ThinkTemplate. class. an error occurs in the php file, that is, it has an endless loop when parsing its own tag include or other tags, resulting in insufficient server memory for this endless loop.

Solution:

1. Locate the problem source. On the template page with the error (Fatal error: Allowed memory size), find the ThinkPHP tag you are using (include/if/empty) and delete the tests one by one, check which tag is causing the problem;

2. Replace the tag you are using with the native PHP, for example:

The code is as follows: Copy code

<! -- My error is caused by include -->
<Include file = "./Public/home/js/Company/companyJS.html"/>
<! -- Change to -->
<Php> include './Public/home/js/Company/companyJS.html'; </php>

For empty reason, refer to the above:

The code is as follows: Copy code

<Php>
If (empty ($ )){
Echo 'A is blank'
}
</Php>

Php prompts Fatal error: Allowed memory size error. Modify the php. ini configuration.

1. Modify php. ini)

The code is as follows: Copy code

Memory_limit = 12 M

2. Add the following statement to the program:

The code is as follows: Copy code

Ini_set (''memory _ limit '', ''12m '');

3. Create a directory in the root directory

Add the following content to the. htaccess file:

The code is as follows: Copy code

Php_value memory_limit 12 M

If it cannot be solved, it should be larger.


The last note is to restart the server.

Or: provide a solution

Add at the beginning of the. htaccess file

The code is as follows: Copy code
Php_value max_execution_time 1200
Php_value memory_limit 200 M
PHP value post_max_size 200 M
Php_value upload_max_filesize 200 M

For general virtual hosts, you can solve related problems by setting. htaccess to the server. This method also applies to similar problems caused by other php programs.

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.