Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

CakePHP : Fatal error: Allowed memory size of 536870912 bytes exhausted (tried to allocate 52 bytes)

Hi i have a apps running on CakePHP v 1.3. I've updated my wamp server to v2.4.After updating i got this error message.I did these changes into my php.ini settings.


  • memory_limit = 128M
  • file_uploads = ON
  • upload_max_filesize = 128M
  • max_input_time
  • max_execution_time = 300
  • post_max_size = 128M
  • realpath_cache_size = 16k
  • realpath_cache_ttl = 120

But i'm still getting these Error message :

CakePHP : Fatal error: Allowed memory size of 536870912 bytes exhausted 
(tried to allocate 52 bytes) in C:\wamp\www\gtgcrm\cake\libs\model\
datasources\dbo\dbo_mysql.php on line 775

What i missed ? Any Suggestion will be appreciated !

like image 316
Asfaq Tamim Avatar asked Dec 18 '13 05:12

Asfaq Tamim


4 Answers

Increase memory limit in php.ini, this is not is appropriate solution at all.

this case can be also occurred from code e.g infinite loop, process large amount data, or even database queries You should check code, there might have been infinite loop or such type case.

like image 113
Girish Avatar answered Oct 23 '22 16:10

Girish


You can increase memory limit by using in your controller action

ini_set('memory_limit', '256M');

Also you can increase time out limit

set_time_limit(0); Infinite
like image 44
Anubhav Avatar answered Oct 23 '22 14:10

Anubhav


The error is obvious and it is due to exceeding memory limits by setting in your ini files or .htaccess. You can also set via php as Anubhay wrote. Following variables are your concern

php_value post_max_size 1000M
php_value upload_max_filesize 2500M
php_value max_execution_time 6000000
php_value max_input_time 6000000
php_value memory_limit 2500M

You can optimize query data by using cake behavior containable. It is better practice to optimize your code/data rather than increasing memory size.

Thanks

like image 3
Moyed Ansari Avatar answered Oct 23 '22 16:10

Moyed Ansari


Try...
Allowed memory size 
ini_set('memory_limit', '-1');
like image 2
Indrajeet Singh Avatar answered Oct 23 '22 15:10

Indrajeet Singh