I have a pretty "unconventional" setup that looks like this:
I have a VMware virtual machine running Ubuntu Desktop 12.10 with networking set to bridge. Installed inside the VM is nginx, php-fpm, php-cli and MySQL. PHP is 5.4.10.
I have a folder containing all the files for the application I am working on in the host (Windows 7). This folder is then made available as a network share.
The virtual machine then mounts the windows share via samba into a directory. This directory is then served by nginx and php-fpm. So far, everything has worked fine.
I have a script that I run via the php CLI to help me build and process some files. Previously, this script has worked fine on my windows host. However, it seems to throw cannot allocate memory
errors when I run it in the Ubuntu VM. The weird thing is that it's sporadic as well and does not happen all the time.
user@ubuntu:~$ sudo /usr/local/php/bin/php -f /www/app/process.php
Warning: require_once(/www/app/somecomponent.php): failed to open stream: Cannot allocate memory in /www/app/loader.php on line 130
Fatal error: require_once(): Failed opening required '/www/app/somecomponent.php' (include_path='.:/usr/local/php/lib/php') in /www/app/loader.php on line 130
I have checked and confirmed the following:
/www/app/somecomponent.php
definitely exists.The permissions for
/www
and all files and sub directories inside are set to execute and read+write for owner, group and others.I have turned off APC after reading this question to see if APC is the cause, but the problem still persists after doing so.
php-cli
is using the samephp.ini
asphp-fpm
, which is located in/etc/php/php.ini
.memory_limit
inphp.ini
is set to128M
(default) which seems plenty for the app.Even after increasing the memory limit to
256M
, the error still occurs.The VM has 2GB of memory.
I have been googling to find out what causes cannot allocate memory
errors, but have found nothing useful. What could be causing this problem?