2
votes

I am running into an issue with a project I am working with on my localhost, where I am unable to increase the PHP memory_limit setting.

I've tried increasing it directly in the php.ini config:

memory_limit = 1024M

I've tried increasing it in the projects .htaccess file:

php_value memory_limit 1024M

I've tried increasing it directly in the function of the PHP controller:

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

Yet none of these actually increases the memory limit for the project, and echoing out phpinfo() confirms that the memory_limit has not been changed.

I've checked the Loaded Configuration File setting in phpinfo() to ensure that I modified the correct php.ini file, and that no other additional config files are being parsed, that could conflict with this setting, but I am still unable to get the setting to increase.

Configuration File (php.ini) Path /etc/php5/apache2

Loaded Configuration File /etc/php5/apache2/php.ini

Scan this dir for additional .ini files /etc/php5/apache2/conf.d

Additional .ini files parsed /etc/php5/apache2/conf.d/05-opcache.ini, /etc/php5/apache2/conf.d/10-pdo.ini, /etc/php5/apache2/conf.d/20-curl.ini, /etc/php5/apache2/conf.d/20-json.ini, /etc/php5/apache2/conf.d/20-memcached.ini, /etc/php5/apache2/conf.d/20-mysql.ini, /etc/php5/apache2/conf.d/20-mysqli.ini, /etc/php5/apache2/conf.d/20-pdo_mysql.ini, /etc/php5/apache2/conf.d/20-readline.ini

Any ideas from the community as to what else I could try? I am using PHP v5.5.9.

1
the .htaccess should have overwritten the apache config settings, but you might want to try increasing defaults there too. I've never run into that. - RightClick
Did you restart Apache after you changed the php.ini? - Reeno
What's your version of PHP? Short notation such as "1024M" is only available since 5.1.0 and can be used only in php.ini (php.net/manual/en/faq.using.php#faq.using.shorthandbytes). You can try to write it in bytes 1073741824. - Mat
Yes, I restarted Apache after the changes. I'm using PHP v5.5.9 - McWayWeb
Are you using ini_get to read the memory limit or waiting for an error? Have you checked for auto-prepends? Overrides elsewhere in the code? BTW increasing the memory allocation, especially to such a large value should be a last-resort, even if you're using cackePHP. - symcbean

1 Answers

1
votes

So it turns out the memory limit was being increased properly, just not being reflected in phpinfo(). The reason it was not reflecting in the phpinfo() echo, is because I was making the memory increase in the controller, and then echoing phpinfo() from the view, so the increase was not being reflected in the view.

Using ini_get() helped me trace the memory limit across the request.