Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Allowed memory size of 33554432 bytes exhausted (tried to allocate 43148176 bytes) in php

This error message is being presented, any suggestions?

Allowed memory size of 33554432 bytes exhausted (tried to allocate 43148176 bytes) in php

like image 582
panidarapu Avatar asked Jan 06 '09 08:01

panidarapu


People also ask

How do I fix PHP fatal error allowed memory size?

The correct way is to edit your php. ini file. Edit memory_limit to your desire value. As from your question, 128M (which is the default limit) has been exceeded, so there is something seriously wrong with your code as it should not take that much.

How do I fix the allowed memory size 1610612736 bytes exhausted?

Try prefixing your command with COMPOSER_MEMORY_LIMIT=-1 . This will remove the memory limit for the execution of the command. Update: Memory exhaust errors should now be resolved by using Composer 2.

What is the maximum PHP memory limit?

Increasing the PHP memory limit The default memory limit is 256M and this is usually more than sufficient for most needs. If you need to raise this limit, you must create a phprc file.


2 Answers

At last I found the answer:

Just add this line before the line where you get error in your php file

ini_set('memory_limit', '-1');

It will take unlimited memory usage of server, it's working fine.

Consider '44M' instead of '-1' for safe memory usage.

like image 86
panidarapu Avatar answered Oct 07 '22 18:10

panidarapu


Here are two simple methods to increase the limit on shared hosting:

  1. If you have access to your PHP.ini file, change the line in PHP.ini If your line shows 32M try 64M: memory_limit = 64M ; Maximum amount of memory a script may consume (64MB)

  2. If you don't have access to PHP.ini try adding this to an .htaccess file: php_value memory_limit 64M

like image 45
Haider Abbas Avatar answered Oct 07 '22 18:10

Haider Abbas