How to Change the PHP Memory Limit

You can change the amount of memory PHP allots to each request by using a .user.ini file.

Using .user.ini does not change the WordPress memory limit. Check out our tutorial on using wp-config.php to increase your WordPress memory limit.

First, create a file named .user.ini in your app's web root directory.


Change the Memory Limit

Then, enter the following line with the new value for your app's memory limit (512 megabytes, for example):

memory_limit = 512M

Disable the Memory Limit

You can also disable the PHP memory limit for your app by entering the following line:

memory_limit = -1

Verify the Changes

To confirm the customizations to your app's .user.ini file are correct, you can create a PHP script that contains only the following line:

<?php phpinfo(); ?>

and then request that file through your browser. You should see the "Local value" for your modified setting showing the value you've set in your .user.ini file.

Restarting PHP is not necessary when you make changes to the local settings as shown in this tutorial.

Last updated: May 23, 2017