开发者

Allowed memory size of 33554432 bytes exhausted (tried to allocate 12 bytes) [duplicate]

This question al开发者_StackOverflowready has answers here: Closed 12 years ago.

Possible Duplicate:

Allowed memory size of 33554432 bytes exhausted (tried to allocate 43148176 bytes) in php

hi, i m tring to run the program, but I keep getting this error; Fatal error: Allowed memory size of 33554432 bytes exhausted (tried to allocate 12 bytes) plz, help me


Here is a simple tutorial here it will work.

This error message can spring up in a previously functional PHP script when the memory requirements exceed the default 8MB limit. Don’t fret, though, because this is an easy problem to overcome.

To change the memory limit for one specific script by including a line such as this at the top of the script:

ini_set("memory_limit","12M");

The 12M sets the limit to 12 megabytes (12582912 bytes). If this doesn’t work, keep increasing the memory limit until your script fits or your server squeals for mercy.

You can also make this change permanently for all PHP scripts running on the server by adding a line like this to the server’s php.ini file:

memory_limit = 12M

Keep in mind that a huge memory limit is a poor substitute for good coding. A poorly written script may inefficiently squander memory which can cause severe problems for frequently executed scripts. However, some applications are run infrequently and require lots of memory like importing and processing a big data file.

In case you need any more help please do not hesitate to reply here.


There might be running infinite loop paste your code here for better answer


Locate your php.ini file and edit the memory_limit field


Increase max_memory in your php.ini file.


Either increase the memory limit defined in php.ini, or rewrite your code to use less memory (e.g. by freeing up resources or variables that won't be cleaned automatically by PHP's garbage collection), or give us more detail so that we can try to help. "trying to run the program" doesn't really tell us much, eg. what program?


Before you change the memory limit you should check if your code needs that much memory in the first place. It's a very unusual scenario for that to be the case - usually this is an indicator of:

1) incorrect config elsewhere, e.g. in webserver

2) inefficient management of resources in your code

3) unbounded loops/recursion

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜