Laravel Memory: 'out of memory (allocated 262144)' - php

I'm a system administrator which handles a server that hosts an internal api created using Laravel 5. The data source is a SQL Server hosted on another server and the api is used in a IOS app for mobile phones. When the developers created the api, this error was not present and no other memory errors were found. When we went live this error has been popping up from time to time.
[2015-06-01 23:01:52] production.ERROR: exception 'Symfony\Component\Debug\Exception\FatalErrorException' with message 'Out of memory (allocated 262144) (tried to allocate 140189808036120 bytes)' in Unknown:0
I checked RAM, CPU, swap etc etc of the server but everything was ok. Not much of the resources are being consumed. I've checked PHP Memory limit from php.ini and is set to -1 which is the max according to PHP. I've checked it on CLI, phpinfo.php and httpd.conf I don't see anything wrong. The team tried following this link Allowed memory size of X bytes exhausted
This is a problem in the ios app because the app searches for a correct return code but when this error comes out, even if the ios app transaction is correct, it returns an error because the return code is incorrect as it is returning the code for the memory error.

The first thing I could think of was to restart the Apache httpd service. This immediately solved the issue. but I knew this is not a permanent fix for the issue. When I researched further, I got to know that the error comes when certain PHP scripts require more memory than PHP was allowed by default.
So the solution is to increase the memory allocated for PHP. How to do that? There are 4 possible ways –
Try looking for the php.ini file. You might find some redundant php.ini files, so make sure you have got the one which is actually being read by PHP. o be sure, create a new php file in your root folder, say “check.php” and have phpInfo(); within the php open and close tags. Execute this file to get the information on where the php.ini is residing. Normally it will be in /usr/local/lib/php.ini
Open the php.ini file in a text editor like TextPad (not in Notepad) and change the values for memory_limit. By default you should see memory_limit = 8M. Try changing it to 12M. If it doesn’t work, increase it to 16M or even 24M and so on.
In case you can’t find the php.ini file or do not have access to it, then open up the file which was throwing the error (admin.php in my case) and add a line below just after ini_set(’memory_limit’, ‘12M’);
You can even consider adding a line in .htaccess file which will resolve the issue.
php_value memory_limit 32M
Or else, Try adding this line to your php file:
Increasing memory allocated to PHP
ini_set(“memory_limit”,”16M“);

Related

Prestashop: Out of Memory (allocated ...) in ../../../classes/Configuration.php

Prestashop suddenly gives an http 500 error. I turned on error log and got this:
"Fatal error: Out of memory (allocated 709623808) (tried to allocate
130968 bytes) in
/var/www/vhosts/44/252639/webspace/httpdocs/shop.mywebsite.com/classes/Configuration.php
on line 206".
I double checked the Configuration.php on line 206 and it's just a standard prestashop file, nothing weird in it. After all it's an "Out of memory" error so maybe I should increase memory.
phpinfo() shows memory_limit 1024M, which is already pretty much, but maybe I should try 2048M. I tried to create a new custom php.ini but that did not work, because (according to phpinfo) the loaded ini file is searched in this directory: /opt/alt/php56/etc.
My hosting provider does not allow me to edit it, it's read only.
What could I do to solve the problem ?
I did not make a backup yet.
I fixed it. It had nothing to do with not having enough memory or whatever. Someone created a product and that caused errors, I don't know what exactly but for everyone in the future:
Create a backup
Turn off third party modules
Delete all products
Delete cache
etc etc. until your webpage loads correctly again ->
after that, restore your backup and just delete what caused the error.
Hope it will work.

Out of memory error uploading images in wordpress

I'm having some problems uploading images in WordPress.
The images them selves are around 1-2mb and width/height is quite big 1000px+ X 1000px+ but the client wants to be able to upload them and let WordPress do the re-sizing.
However when trying to upload I'm getting the following error:
"Fatal error: Out of memory (allocated 28573696) (tried to allocate 4096 bytes)"
Now I understand that this means the server doesn't have enough memory to process the image but when I do a phpinfo() check on the server it tells me that I have 256M of memory.
So why would I be getting a fatal error message saying I'm only allocated 32M?
The website itself is hosted by someone else so I don't have access to a php.ini or any of the error logs.
Thanks In advance,
Mark,
Even with a very high memory limit, GD will run out of memory processing a full-size photo from a mid-level digital camera. If your server has ImageMagick on the command line, you could use that. When ImageMagick resizes an image it uses a relatively small amount of memory and it is not subject to the PHP memory limit.
I found a WordPress plugin called ImageMagick Engine that claims to make WordPress use ImageMagick instead of GD. I've never used that plugin myself though.
phpinfo may be showing you memory for the php config for the whole server rather then the shared account you are using. You may not be able to override with your own php.ini due to the main php config file restricting use of php.ini files.
Try adding the 'define" line below to wp-config.php a few lines of white space below the opening <?php in the file:
define('WP_MEMORY_LIMIT', '64M');
This may be able to override shared settings to give you more memory.
Turned out to be an issue with the company hosting the site limiting the memory allocated. Moved to a new host and the problem was sorted.

Magento Random Fatal Error

I have a VPS apache server based in a farm.
Recently i sufferd from memory limit errors and i decided to increase the number of the memory limit by changing it in the WHM panel at PHP Configuration to 256MB. after i was presss the button "Save", i got my site (and other wordpress sites i have in my server) all over with random fatal errors and 500 internal server errors on my site: http://amadeus-trade.ru
I can log into the backoffice but, when i tried to go to System -> Configuration i get this error:
Internal Server Error
The server encountered an internal error or misconfiguration and was unable to complete your request.
Please contact the server administrator, webmaster#amadeus-trade.ru and inform them of the time the error occurred, and anything you might have done that may have caused the error.
More information about this error may be available in the server error log.
Additionally, a 500 Internal Server Error error was encountered while trying to use an ErrorDocument to handle the request
And when i try to add products i get this error:
Fatal error: Out of memory (allocated 19922944) (tried to allocate 1245184 bytes) in /home/amadeus/public_html/app/code/core/Zend/Date.php on line 2423
This error allways jumps from file to file and looks like this scheme:
Fatal error: Out of memory (allocated xxxxxxxx) (tried to allocate xxxxxxx bytes) in /home/amadeus/public_html/xxx/xxxx/xxx/xx/xx.php on line xxxx
Now, It is fresh installation. so far (until 01.11.12) the website worked great without problems.
The team in the hosting company says that this is aproblem of a code in magento but i positivly sure that the problem is on the server!
My WHM version was update by the team in 01.11.12 to v11.30
Can you assist me please how to solve this?
Looking at your error message
Fatal error: Out of memory (allocated 19922944) (tried to allocate 1245184 bytes)
in /home/amadeus/public_html/app/code/core/Zend/Date.php on line 2423
PHP is telling you it tried to allocate 1,245,184 bytes of memory, but that was over the limit allowed. It's also telling you there are currently 19,922,944 bytes allocated.
1,245,184 bytes is 1,216 kilobytes (KB), which is 1.1875 megabytes (MB).
19,922,944 bytes is 19,456 kilobytes (KB), which is about 19 megabytes (MB).
This means one of two things.
PHP thinks it's only allowed to allocate around 19 MB of memory
The operating system PHP is running on ran out of memory
Check your runtime php.ini settings to make sure your memory change stuck (use a single page calling the phpinfo function to do this). Also, make sure it's 256M, and not 256MB. The later won't be recognized by PHP, and "weird things" will happen (including a super low memory limit).
That said, my guess is it's the later. When my version of PHP goes over the limit set in the memory_limit ini, I get a slightly different error.
PHP Fatal error: Allowed memory size of 262144 bytes exhausted (tried to allocate 10493952 bytes)
PHP is telling me that it's allowed limit has been violated. Your error
Fatal error: Out of memory
Says PHP has literally used up all the memory avaiable to the server at that point in time.
Beyond that, you host's response show a lack of Magento specific knowledge — any host capable of running the system would be able to the give you the information I just did. I'd start by asking them what the maximum memory limit is for a single PHP request. I'd end by moving to a VPS host that advertising Magento capability and has a good reputation for it.
Could it be that 256M was lower than it originally was set to? As it sounds like you already know, Magento requires a minimum of (get this) 256mb of ram, and 512 is recommended, and certainly more for larger applications.
Run a phpinfo() command and see what the memory_limit property is set to. If you can, use your .htaccess to change the limit to a more reasonable level:
php_value memory_limit 512M
However, I must say that there is a good chance that your hosting provider will frown on changing this setting (if they don't allow you to do it in .htaccess).

WordPress: Upload Plugin stuck at "Unpacking the package…", Getting Memory Size Limit Error

I just did a fresh install of WordPress 3.2.1. I've uploaded and activated one plugin with no problem - Contact Form 7. I'm attempting to install Really Simple Captcha, since it goes along with Contact Form 7.
But, when I go to install it (either upload from my computer or install from WP, doesn't make a difference), it gets stuck at "Unpacking the package...". I check my server error logs, and they have the following:
PHP Fatal error: Allowed memory size of 16777216 bytes exhausted (tried to allocate 311296 bytes) in <mysite>/wp-includes/class-simplepie.php on line 4186, referer: <mysite>/wp-admin/index.php
I've searched this error, and they recommend changing the memory limit to 64m or 128. I tried this, but I still get the same "Allowed memory size of 16777216 bytes" error - even though I've changed the memory limit, it still shows the same number.
I've added define('WP_MEMORY_LIMIT', '128M'); to /wp-config.php and to /wp-includes/default-constants.php . I've also added ini_set("memory_limit","64MB"); to /wp-config.php .
I tried another solution of adding AddType x-mapp-php5 .php to .htaccess, but that wouldn't load my site - gave me error [warn] Cannot get media type from 'x-mapp-php5'
What the heck am I doing wrong?
You need to change the memory_limit in the php.ini for your server. Changing it at runtime has typically no effect (on shared hosting anyway), much less the WP_MEMORY_LIMIT constant.
If safe_mode and other restrictions are not enabled, then php_value via .htaccess or in a .user.ini for CGI setups might work.
For me the problem solved with disabling "JCH OPTIMIZE" Plugin

Need to increase PHP memory_limit for specific directory NOT entire server

I'm running wordpress 2.8.6 as fcgi with safe_mode=on, on plesk9/centOS64. wordpress was installed by installatron. php.ini is being read from /etc/etc/php.ini
I need to increase php's memory_limit, because I get many mod_fcgid: stderr: PHP Fatal error: Allowed memory size of 33554432 bytes exhausted (tried to allocate 40961 bytes) in /var/www/vhosts/domain.com/httpdocs/wp-content/plugins/blah/blah.php on line X when I try to upgrade most WP plugins.
Following instructions on http://www.sakinshrestha.com/wordpress/fix-php-fatel-error-for-wordpress/, i tried creating both a php.ini and an htaccess file and placing it in /var/www/vhosts/domain.com/httpdocs/wp-content/. It didnt work. I did not try using both files at the same time. apache was restarted each time i created those files.
I thought not being able to use the setting per folder could be due to the fact that I am using fcgi. I switched the domain to use mod_php. Now when I try to upgrade a plugin I get a box asking for FTP login info (as seen in http://www.chrisabernethy.com/why-wordpress-asks-connection-info/). I put in the correct FTP login info, but when I click continue, the server tries to get me to download update.php.
So now i have two questions:
1) how do i increase memory_limit for that folder only under FCGI?
2) how do i switch to mod_php and configure WP to NOT need FTP connection info? I tried following the instructions in the last link above, but <?php echo(exec("whoami")); ?> is blocked by PHP Warning: exec() has been disabled for security reasons in /var/www/vhosts/domain.com/httpdocs/whoami.php on line 3. i turned safe_mode=off but it didnt make a difference.
arrrrghhhhh!!
As of PHP 5.3 you can use .user.ini as an configuration file per User.
Best wishes,
Fabian
Why in wp-content? Try creating a php.ini in /var/www/vhosts/domain.com/httpdocs.
Also, did you edit wp-settings.php? This is the default:
if ( !defined('WP_MEMORY_LIMIT') )
define('WP_MEMORY_LIMIT', '32M');

Categories