0

I'm using CakePHP 2.3 I'm getting this error when accessing a CakePHP website:

PHP Fatal error: Allowed memory size of 134217728 bytes exhausted (tried to allocate 4386075 bytes) in C:\inetpub\wwwroot\mysite\lib\Cake\Event\CakeEventManager.php on line 246

It doesn't seem to be a loop, looks like something related with sessions as it fails just after trying to read a session variable with $this->Session->read('Auth.User.isAdmin').

Before that, I can print and die() without problems.


Update:

PHP Fatal error: Allowed memory size of 536870912 bytes exhausted (tried to allocate 12273327 bytes) in C:\inetpub\wwwroot\tlm\lib\Cake\Event\CakeEventManager.php on line 246

Update 2

After setting the limit to 1500M

PHP Fatal error: Out of memory (allocated 1307312128) (tried to allocate 23778447 bytes) in C:\inetpub\wwwroot\tlm\lib\Cake\View\View.php on line 926 PHP Fatal error: Maximum execution time of 30 seconds exceeded in C:\inetpub\wwwroot\tlm\lib\Cake\Error\ErrorHandler.php on line 116

Update 3

I'm using PHP 5.5.6. After updating to CakePHP 2.6 by replacing the lib folder, I'm getting the same error multiple times and after like 30 lines of that same error, I get the memory one.

PHP Strict Standards: Only variables should be assigned by reference in C:\inetpub\wwwroot\tlm\app\Plugin\Combinator\View\Helper\CombinatorHelper.php on line 33

PHP Strict Standards: Only ...

PHP Strict Standards: Only ...

PHP Fatal error: Allowed memory size of 134217728 bytes exhausted (tried to allocate 3704512 bytes) in C:\inetpub\wwwroot\tlm\lib\Cake\View\View.php on line 958

PHP Strict Standards: Only variables should be assigned by reference in C:\inetpub\wwwroot\tlm\app\Plugin\Combinator\View\Helper\CombinatorHelper.php on line 33

PHP Strict Standards: Only ...

PHP Strict Standards: Only ...

Alvaro
  • 40,778
  • 30
  • 164
  • 336
  • This is not a cakephp specific problem, you probably have an infinite loop or something similar that is consuming all your memory. – José Lorenzo Rodríguez Nov 03 '14 at 15:46
  • 2
    Update to the current master branch version where the stacktrace for fatal errors are printed now as well ( https://github.com/cakephp/cakephp/pull/5053 ). And debug it this way to have more information on what happened. – mark Nov 03 '14 at 15:50
  • @mark changing from version 2.3 to the current one 2.6 I'm afraid some things can stop working due to internal changes in cakePHP. – Alvaro Nov 03 '14 at 15:57
  • 1
    @Alvaro , at least u can try 2.6 on Development instance – Pratik Joshi Nov 03 '14 at 16:07
  • @jQueryAngryBird updated to 2.6. I've updated my question with the latest errors. – Alvaro Nov 03 '14 at 16:15
  • Combinator plugin Doesnt work :) try letest version of it too. – Pratik Joshi Nov 03 '14 at 16:21
  • You can also cherry pick the changes in that PR :) No need to fully upgrade just for getting a strack trace my friend. – mark Nov 03 '14 at 16:45
  • Looking at your third update, it doesn't seem that you have installed/enabled xdebug (which is required for the change mentioned by @mark)!? – ndm Nov 03 '14 at 17:25
  • I thing that is a error in a bucle or pagination or maybe when do you want show the data, do you have a db of test? because you need a db with just a few files and this can give you a error more specific. – CoolLife Nov 03 '14 at 18:23

4 Answers4

1

In such cases it helps to temporary put this method in AppController:

public function appError($method, $messages) {
    die('Application error: called handler method ' . $method);
}

This usually gives me a hint where to look further.

bancer
  • 7,475
  • 7
  • 39
  • 58
0

Edit php.ini and set memory_limit to great extent than currently set.

Like set memory_limit = 512M

Update

increase max_execution_time

Pratik Joshi
  • 11,485
  • 7
  • 41
  • 73
0

After experiencing a similar error, it looks like the problem exists in CakeSession.php line 489:

throw new CakeSessionException(sprintf(
    __d('cake_dev', 'Unable to configure the session, setting %s failed.'),
    $setting
));

This seems to be causing the infinite loop, and exiting here will stop it. I don't know exactly why this is causing a loop, but the the reason it does is because CakePHP can't set some of your php.ini variables using ini_set. If you print out $setting and $value at this point you'll be able to see what the problem variables are. For me is was session.auto_start, which was set in the _defaultConfig function in this file. I commented out the lines which set this which resolved the issue for me.

Loftx
  • 1,760
  • 4
  • 29
  • 50
0

I had the same error and this helped:
I simply changed the $this->set('votingBookings') into $this->set('bookings') in the controller file. hope that helps anybody. Love SO and want to contribute my 2 cents. cheers :D

Niki van Stein
  • 10,564
  • 3
  • 29
  • 62
akeen
  • 1