1

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.

Community
  • 1
  • 1
Drew
  • 710
  • 1
  • 15
  • 34
  • could you please post your config file here? – Sujit Agarwal Jun 02 '15 at 04:37
  • apache or php config? – Drew Jun 02 '15 at 05:10
  • I misread your question. I don't think laravel is overruling the limits. But you could grep the code your developers provided for any php dynamic overrule. Still I do think it's caused by wrong php.ini settings. – Luceos Jun 02 '15 at 06:37
  • I still don't get it why it's still getting errors about memory. I followed this solution [link] (http://stackoverflow.com/questions/26636980/php-memory-allocation-limit-causes) but I'm still getting errors. Any more idea? – Drew Jun 02 '15 at 23:49
  • i am getting same issue from last 2 hours, i set max limit at php.ini and clean cache multiple times, but did not work – Ravi Mane May 11 '18 at 09:26

1 Answers1

-1

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 –

  1. 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.

  1. 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’);

  2. You can even consider adding a line in .htaccess file which will resolve the issue. php_value memory_limit 32M

  3. Or else, Try adding this line to your php file: Increasing memory allocated to PHP ini_set(“memory_limit”,”16M“);

Anilkumar S.K
  • 107
  • 2
  • 6