I'm getting the following error when trying to run a php script I wrote:
Fatal error: Allowed memory size of
33554432 bytes exhausted (tried to
allocate 56320 bytes) in
/home/evergrf2/public_html/ianburris/p/maptile/mapfetcher.php
on line 43
What confuses me is that it says the allowed memory size is 33554432 bytes and that when the script tried to allocate 56320 bytes of space the allowed memory was exhausted. How is this possible when 56320 is less than 33554432? Maybe I'm misinterpreting what this is saying...
It says that trying to allocate additional 56320 bytes caused memory exhaustion (so it already had at least 33498112 bytes allocated).
allocation of 56320 pushed you above the limit. Increase your limit in php.ini if needed.
to be more clear dont read it as alocating 56320 is more than allowed 33554432. Instead read it as, while allocating 56320, we surpassed the limit of 33554432.
Modified: dont increase without properly debuging and making sure there are no memory leaks.
33554432 bytes is 32MB, which is not huge.
You can increase PHP's memory limit (in php.ini, look for a line that reads 'memory_limit = 32M' and modify it appropriately). I generally use 128M for development and heavy number-crunching.
The other solution is to profile and rewrite your code to use less memory.
I would also profile the script with the help of Xdebug,
to help find possible memory leaks.
Related
Getting the following error, which I understand and have seen before. But one thing seems weird, it is trying to allocate an amount which is lower the the allowed memory size. Doesn't this seem weird?
Fatal error: Allowed memory size of 33554432 bytes exhausted (tried to allocate 7680 bytes) in XXX on line 93
Could this be some kind of misconfiguration with memory management, I am using a cloud server.
The number "tried to allocate 7680 bytes" does not mean the total amount of memory the script allocates, but the last portion on which it exceeded the limit.
So let's say your script already allocated 33550000 b, tries to allocate another 7680 b. The total exceeds the memory limit and that's why the error appears.
Maybe the memory limit is set smaller than what you're thinking it is set to?
You can use this to display the current limit
echo ini_get('memory_limit');
or increase it inline with
ini_set('memory_limit', '64M');
Of course you can see the entire php enviornment with
echo phpinfo();
I'm getting this error:
Fatal error: Allowed memory size of 67108864 bytes exhausted (tried to allocate 3456 bytes) in /home/gigiphot/public_html/Includes/thumbnail.inc.php on line 158
and this PHP memory limit is set to 64mb .. do I increase it? Not sure of next step...
You can set memory_limit in your php.ini file, see here: http://php.net/manual/en/ini.core.php
However, you may want to investigate if you really need such a heavy memory consumption... if this service will be used by multiple users concurrently, you may have problems... An unintended high memory consumption is often a symptom of something going wrong in your script.
Try adding ini_set('memory_limit', '128M'); to the top of the file.
You can set it to -1 to ignore the limit, but it's not generally recommended.
This question already has answers here:
Closed 11 years ago.
Possible Duplicate:
Allowed memory size of 33554432 bytes exhausted (tried to allocate 43148176 bytes) in php
I've seen similar problems here, but mine is quite different. I am reading from database and writing to an xml file. I get this error
<b>Fatal error</b>: Allowed memory size of 67108864 bytes exhausted (tried to allocate 4459414 bytes) in <b>.../public/home/..</b> on line <b>32</b><br />.
What should be the solution? Do I increase the memory size in code? Any help?
Try to increase or remove memory_limit in php.ini.
Find something like this and change value of memory_limit
; Maximum amount of memory a script may consume (128MB)
; http://php.net/memory-limit
memory_limit = 128M
(this is part of my php.ini)
Restart server after saving changes.
Also, you can try to remove limit from code.
Example:
ini_set('memory_limit', '-1');
That should work fine.
Another way is setting memory limit from .htaccess file by adding line:
php_value memory_limit 128M
(128M is just an example)
Note: For shared hosting I highly doubt you can change memory limit.
Do a mysql_unbuffered_query() rather than mysql_query(). Your query is probably returning too much data as is for your php server to handle.
I am having really weird problem:
Fatal error: Allowed memory size of 134217728 bytes exhausted
(tried to allocate 21748 bytes)
I understand that error however I am tracking all memory allocation for script and its not getting above: 2883584 in total.
The line before Fatal error is being triggered real memory usage is at a level of 2883584. As described in error above script is trying to allocate just extra 21748 more which is not adding up to 134217728 anyway.
Any ideas why its like that?
P.S.
for memory allocation usage I am using: memory_get_usage(true) function.
Consider passing true to memory_get_usage, which will return the true amount of system memory allocated (rather than just emalloc usage). The runtime is probably referring to system memory used when terminating your script, which may be much higher (e.g. through extensions which are not emallocing values).
OK, so I think I have found out the problem. As it turns out, if there is hard image to process GD2 allocation memory but you can't see it in memory_get_usage and get_peak so quite lame but...
This question already has answers here:
Closed 12 years ago.
Possible Duplicate:
Allowed memory size of 33554432 bytes exhausted (tried to allocate 43148176 bytes) in php
Hi,
In my php page, I got the error as follows,
Fatal error: Allowed memory size of 134217728 bytes exhausted (tried to allocate 71 bytes)
I tried to set memory limit using ini_set('memory_limit', '128M');
But still I got the error.
Any help would be really appreciated.
128 megabytes is 134,217,728 bytes. You've used up that memory. You either need to set the limit higher (if you can; I don't know if PHP will allow that) or simply use less memory in your code.
Do you expect your page to be using a lot of memory? If so, maybe raising the limit (or setting it to -1, which is somewhat dangerous in terms of allowing unlimited memory use) is the right thing to do. If not, look through your code for places where you could be effectively leaking memory. You might want to try replacing sections of your page with "dummy" blocks, one at a time, until you find the offending section.