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.