i got a very strange problem with my code running on PHP 5.2.8 + IIS6 ISAPI virtual host.
the page reports error "Fatal error: Allowed memory size of 268435456 bytes exhausted (tried to allocate 536870912 bytes)" when i'm using the following code.
$comments = $Comment_Model->getComments(2, $logid, 'n', $commentPage);
extract($comments);
but if i'm not using the "$comments" to extract, no error reports.
extract($Comment_Model->getComments(2, $logid, 'n', $commentPage));
what i have tried:
increase more memory by adding ini_set('memory_limit', '') into my script, not works.
move the script to other servers, it works.
it looks like an environment problem, does anyone has a clue?
I had the same problem with ini_set() not working for upping the memory limit on my shared hosting. Depending on your server's setup, some ini options are not allowed to be changed via ini_set().
You may have to edit the php.ini file, which some hosting providers will allow, and some not. I would also suggest that you make sure your script really should need that much memory (not a problem with the code).
I hope that helps.
Related
On my localhost, the process in question works fine. It's basically a whole lot of number crunching.
But on my server (CentOS 5.9 + PHP 5 + MySQL 5) it gives me this error:
Fatal error: Allowed memory size of 33554432 bytes exhausted (tried to allocate 80 bytes) in {..}/system/database/drivers/mysql/mysql_result.php on line 147
I'm already declaring the following before running this function:
ini_set('memory_limit', '-1');
The system itself has 8 GB of memory. My local machine has 12 GB of memory. I doubt it needs that much memory, though.
Any insights would be greatly appreciated. Thanks in advance!
PHP has a global memory limit on each system where it runs that overrides your program's own memory_limit setting.
It's the memory_limit value in a file called php.ini. Shared hosting providers often set this to something like 32M. That seems to be your problem. If you control the server you may be able to set it larger.
Otherwise you'll need to rework your program to use less memory. (This is a very common problem when moving from development to production, sad to say.)
Here's some advice on finding that file if you don't know where it is.
Dude, where's my php.ini?
When I try to install a package to Contao using the Composer client I get an error:
Fatal error: Allowed memory size of 1073741824 bytes exhausted (tried to allocate 134217728 bytes) in phar://D:/wamp/www/myproject/composer/composer.phar/src/Composer/DependencyResolver/Solver.php on line 220
I am really confused. My PHP memory limit is set at 512M. phpinfo() confirms it. But 1073741824 is a gigabyte! And it still isn't enough, as if the script totally disregards the PHP memory limit (where?) and even a gigabyte isn't enough!?!?
What can I do? I read about RLimitMEM, but I can not find such a setting anywhere on WAMPServer.
I found the answer.
I searched the project for memory_limit and found out, that the composer client attempts to set a memory limit in system/modules/!composer/src/Runtime.php There is this line: #ini_set('memory_limit', '1024M'); I changed it to #ini_set('memory_limit', '2048M'); essentially doubling the available memory, and it worked.
It is recommended to use the so called detached mode for the composer client. If you have a proper CLI environment available, you'll have no memory limit and no maximum execution time. Also both of these limits can be controlled via command line arguments.
However, this does not work in all hosting environments. See this Wiki entry for more details: https://github.com/contao-community-alliance/composer-client/wiki/Execution-modes
I am trying to set up a website using Joomla and this is the error I get after accessing localhost (right after successful installation process):
Fatal error: Allowed memory size of 8388608 bytes exhausted (tried to allocate 98304 bytes) in [...]\default_item.php on line 77
The same thing happens when using Drupal (before installation though). I have already tried changing php.ini (in location given by Joomla itself, so it's the right one. Interestingly, website on localhost does not work, while admin panel on localhost/administrator works, that's where I got the file location from) to look like this:
memory_limit = 512M
I also tried putting ini_set('memory_limit', '512M'); inside the script indicated in error and freeing some of my RAM, but still - no success.
I use WebServ, which uses Apache 2.2.6 and PHP 5.2.5.
What more can I do to overrun this problem?
Edit:
Output of phpinfo(); for Joomla
ini_set('memory_limit', '-1'); overrides the default PHP memory limit.
By the way look out for never ending loops. It might be causing the error.
I'm working on a wordpress website and I'm attempting to set up a local test-environment for development purposes. I'm running the MAMP (Mac Apache MySQL PHP) stack.
I'm running into the following error:
Fatal error: Allowed memory size of 262144 bytes exhausted (tried to allocate 4864 bytes) in /Users/casey/Documents/workspaces/yofreesamples.com/wp-includes/functions.php on line 1174
I've attempted to increase the memory limit by modifying line 28 in wp-config.php:
define('WP_MEMORY_LIMIT', '2024MB');
and by including the following value in index.php
ini_set('memory_limit','64M');
without any luck for any memory values I've tried. I'm relatively new to wordpress, anyone have any idea what's going on?
Perhaps the MAMP configuration doesn't allow you to override the memory limit programmatically. Set it in php.ini as described here.
I have set php memory limit from whm to 256M from WHM > PHP Configuration Editor.
Even so, my wordpress website and admin is showing me an error like below.
Fatal error: Out of memory (allocated 36175872) (tried to allocate 30720 bytes) in /home/XXXX/public_html/wp-includes/class-simplepie.php on line 14272
Fatal error: Out of memory (allocated 35127296) (tried to allocate 1966080 bytes) in /home/XXXX/public_html/wp-includes/class-simplepie.php on line 5427
I also tried to add following line to the top of wp-config.php, but no luck and same error.
define('WP_MEMORY_LIMIT', '128M');
can anyone suggest me or tell me what may be the solution?
I finally think I've solved the White Screen of Death from PHP out of memory Fatal Errors.
Full details here: http://www.isthisyourhomework.com/how-to-fix-the-wordpress-white-screen-of-death/
If setting the WordPress and PHP memory limits doesn't work for you, try adding/edditing the following line in either your Apache conf files. I didn't have access to those, so I added the following line to the .htaccess file in my WP server's document root:
RLimitMEM max
Many hosts have set limits on each user on shared-use servers. The above setting will unfetter your server and banish the WSOD.
The SimplePie people reckon that this is caused by a bug in PHP. It was fixed in PHP version 5.3. Upgrading might help.
Newer versions of SimplePie use less memory but still suffer from the same PHP bug that causes lots of cached items to cause you to use loads of memory.
Did you change the memory limit in php.ini(or through WHM service configuration page)? If so, try rebooting Apache