i got this error when using php bin/console server:run , and the server won't start.
php bin/console server:run
Fatal error: Allowed memory size of 2097152 bytes exhausted (tried to allocate 4096 bytes) in C:\Users\Messkan\Desktop\businessplace\vendor\jms\serializer-bundle\JMSSerializerBundle.php on line 43
Fatal error: Allowed memory size of 2097152 bytes exhausted (tried to allocate 32768 bytes) in C:\Users\Messkan\Desktop\businessplace\vendor\symfony\symfony\src\Symfony\Component\Debug\Exception\OutOfMemoryExce
ption.php on line 1
use this command to increase memory allocated:
php -d memory_limit=-1 bin/console server:run
or increase this option in php.ini in your php folder.
You probably have either:
An entity related to thousands of other entities, and by the time you get to a very high amount of records being serialized, memory maxs out, or...
A circular reference in one of your entities
Increasing the memory limit may fix it if is not a circular reference, but that's not a proper fix. You have to be efficient. Control your hydration and references. Also, IMO, JMS Srializer is not the best tool for a presentation layer. Try league/fractal.
You need to increase memory_limit value in php.ini file for the php version you are using (e.g. php7.0).
So navigate to your php.ini file there, find memory_limit line in this file & try to set value to 1G or 2G (depending on the app size, - how much you really need). Save changes & restart your server (apache/nginx), and try once again.
Related
I have three WooCommerce based shops installed on my server, basically they are identical shops using the same plugins and themes and the assortment is almost identical (product presentation also).
Each store database has less than 100MB.
In one case I have memory problem for PHP scripts, while memory_limit is set to 256M one store still has memory problems. Others work ok.
[01-May-2020 22:23:08 UTC] PHP Fatal error: Allowed memory size of 268435456 bytes exhausted (tried to allocate 14069080 bytes) in /home/shop1/public_html/wp-includes/wp-db.php on line 2951
[01-May-2020 22:33:22 UTC] PHP Fatal error: Allowed memory size of 268435456 bytes exhausted (tried to allocate 10489856 bytes) in /home/shop1/public_html/wp-includes/functions.php on line 708
I can raise the memory_limit to e.g. 384M and the problem disappears. But why does such a script require more than 256MB and the other two do not? Is it normal?
You might have a memory leak or from what I can understand if you have set 256M and each one is 100MB that means you only have space for 2 of them and hence the 3rd one is running out of ram.
Make sure that on your php.ini you put more ram and then assign enough ram to each webstore that does not surpass your overall amount.
Your php.ini is most likely taking over and setting the overall RAM rather than the ram PER instance. Hope that makes sense.
In my PHP web application there is this line:
require_once(__DIR__. '/myfiles.phar');
I'm using this to include a self-created PHAR file with ≈8 MB file size.
One customer has a memory_limit setting of 16M.
In this environment, I do receive an error
Fatal error: Allowed memory size of 16777216 bytes exhausted (tried to allocate 16777216 bytes) in /var/www/my.php on line 3
(See also e.g. here)
Since the customer cannot increase the memory_limit setting value, I'm clueless on how to adjust this.
My question:
Is there any way to tell the PHAR functions in PHP to use less memory when "extracting" PHAR files?
(I'm guessing the the size of my PHAR file is directly linked to the memory usage. So the obvious but complicated way would be to reduce the size of the PHAR file).
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
Hello i am facing the problem of Allowed memory size error. I have created the project in codeigniter, php and I have used Tbs library. Its worked fine but today it display the error:
Fatal error: Allowed memory size of 67108864 bytes exhausted (tried to allocate 258010 bytes) in
/home/abc/public_html/application/libraries/Tbs.php on line
4222
Please give me any suggestions.
If you are using TBS + OpenTBS in order to merge an XLSX file , then there is a known problem fixed with OpenTBS version 1.9.2 : if the number of row to merge is quite numerous, then you can have a very long process or a memory size error when calling $TBS->Show().
Use OpenTBS 1.9.2 or higher which is optimized for this point, and if the process is still long you can optimize more using the OPENTBS_RELATIVE_CELLS command.
"Allowed memory size of XXXXXX bytes exhausted" is a typical error when you don't have, as it's own name says, enough memory available for the php query to run.
Try upgrading memory_limit variable on your php.ini file, or by setting up ini_set('memory_limit', 'XXXM'); on your PHP file that you are running, being XXX the amount of Mb memory that you want to define.
If this isn't the case, you might have a bug in your software that is causing, i.e. a loop that is consuming memory without any control; but as you have said that it did work before...
Anyway, please check all the other answers from StackOverflow on this aspect:
Fatal Error: Allowed Memory Size of 134217728 Bytes Exhausted (CodeIgniter + XML-RPC)
CodeIgniter Fatal error: Allowed memory size of bytes exhausted
Codeigniter - Allowed memory size exhausted while uploading
Generally this type of occurs when your script is using too much memory. This can often happen in PHP if you have a loop that has run out of control and you are creating objects or adding to arrays on each pass of the loop. Check for infinite loops.
If that isn't the problem, try and help out PHP by destroying objects that you are finished with by setting them to null eg. $OldVar = null;.
Check the code where the error actually happens as well. Would you expect that line to be allocating a massive amount of memory? If not, try and figure out what has gone wrong.
Never upgrad memory_limit variable on your php.ini file, or by setting up ini_set('memory_limit', 'XXXM'); on your PHP file that you are running, being XXX the amount of Mb memory that you want to define.Letting application to eat memory he wants to is insane step.Try to find out bug does your application wants that much memory?? Find out
PHP Fatal error: Allowed memory size of 134217728 bytes exhausted (tried to allocate 13374929 bytes) in script.php on line 2
Line 2 is
session_start();.
Sessions are stored in memcached daemon (set via php.ini session.save_path
with default memcached settings (1mb for entry max), meaning session data itself is not supposed to be that big.
Suggestions for debugging?
session.save_handler = memcache
session.save_path="tcp://YOURSERVER:PORT?persistent=1&weight=1&timeout=1&retry_interval=10"
Try to set your php.ini config to something like that...
Session_start itself has no memory overflows.
The error appeared there since this was the straw that broke the camel's back
and nearly the max available memory was allocated already before getting to that line.