PHP memory_limit blocked up to 256 MB?

I am trying to set memory_limit to 512M, but this is locekd to 256M.

ini_set('memory_limit','512M'); ini_get('memory_limit'); //> Returns: 256M 

I have full control over my server. (this is highlighted)

Please note that everything under 512M works.

 ini_set('memory_limit','16M'); ini_get('memory_limit'); //> Returns: 16M 

Decision

I found out why. In php.ini, I had memory_limit = 256M . Perhaps this is considered the upper limit.

+8
php
source share
6 answers

3 possible I can come up with / find:

Prior to PHP 5.2.1, in order to use this directive, it had to be enabled at compile time using --enable-memory-limit in the configure line.

OR

The problem described in detail here: ini_set ("memory_limit") in PHP 5.3.3 does not work at all

OR

ini_set is disabled

+7
source share

You can also try changing memory_limit using the php.ini or .htaccess file

php.ini

 memory_limit = 512M; 

.htaccess

 php_value memory_limit 512M 
+2
source share

I noticed that on my Mac (OS X El Capitan) and the new PHP 7.0.0 I cannot change memory_limit via php.ini

But I can change it through / etc / apache 2 / httpd.conf by adding a line to the end:

php_value memory_limit 1024M

and restarting the apache server:

sudo apachectl restart

And this is the correct php.ini, I can change other settings through it.

+1
source share

You can check your php.ini configuration file in a directive called "disable_functions". Check if the ini_set function is disabled.

Also, if safe_mode is enabled, this option cannot be overridden.

0
source share

I found out why. In php.ini, I had memory_limit = 256M . Perhaps this is considered the upper limit.

I applied it to my need.

0
source share

A bit late, but editing the php.ini file does not work for php 7.1 using Mac OS 10.11.6. I still continued to get "PHP Fatal error: Allowed memory size of ....", which in its value showed that the memory parameter was not updated after apache started.

So, instead of editing the file.

 /usr/local/php5/lib/php.ini 

I found that modifying the following file fixed this problem.

 /usr/local/php5/php.d/99-liip-developer.ini 

This file actually replaced the values โ€‹โ€‹set in the php.ini source file. Making the following changes to the line again ...

 memory_limit = 256M 

to

 memory_limit = 1024M 

And restarting apache.

 sudo /usr/sbin/apachectl restart 
0
source share