简体   繁体   中英

PHP Out of memory, but only on one system

I have been working for the last few months on a CakePHP application.
Most of this time I was developing on Lubuntu, using lampp package.
Everything works fine in this setting, as it does on two different remote servers I have access to.
Few days ago circumstances forced me to move with the development to a laptop device with Windows 7 as an OS.
And the application doesn't work here. contained Allowed memory size of 134217728 bytes exhausted . 包含Allowed memory size of 134217728 bytes exhausted
I've switched memory_limit to -1 in , and now it's PHP Fatal error: Out of memory (allocated 1488453632) (tried to allocate 15470592 bytes) 中将memory_limit切换为-1 ,现在它是PHP Fatal error: Out of memory (allocated 1488453632) (tried to allocate 15470592 bytes)
This smells like an infinite loop, but the application still works correctly on other servers. And other applications, including freshly downloaded Cakephp package, work fine on this device.

I'm confused with the apparent exclusiveness of this error. I can provide additional information if you tell me what should I check.


- recursive was at 3 , but setting it to -1 haven't changed anything. Also, in most cases we set recursive individually for each find(...) call.
-setting debug to 0 brings no noticeable changes.


I have solved the issue, sort of. I'll Provide details in the answer.

I have found the source of the problem, although I only understand it partially. The reason lies in \\lib\\Cake\\Model\\Datasource\\CakeSession.php :

if (ini_set($setting, $value) === false) {
throw new CakeSessionException(sprintf(
    __d('cake_dev', 'Unable to configure the session, setting %s failed.'),
    $setting
)); }

This line was throwing the exception over and over for setting session.auto_start . It appears that the expression 0 === false incorrectly returned true . I assume that because phpinfo() displays that session.autostart is off. I could print out the value just before the block in question, but if for some unknown reason comparison really is wrong, then why would printing be correct? I don't have the time to investigate this further. I have commented the exception for the time of development. On production server everything works fine.

Try adding ini_set('memory_limit', '1G'); To the top of the offending php page, and see if it runs.

If you still receive the error. Check the Apache error log for the line which the offending code is on to see if you are indeed stuck in a recursive loop.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM