Are you getting a WordPress error while uploading any file that says “Allowed memory size exhausted”?
This is a common WordPress error and you can easily solve it on your own to increase PHP memory limit in your Cpanel or web hosting panel.
Reason behind getting error: WordPress Allowed memory size exhausted
In WordPress there is a certain memory limit i.e. 32MB has been allocated for uploading any kind of plugins, media files, and themes. But in some cases, some plugins and themes have huge file sizes that cause this WordPress error.
Fatal error: Allowed memory size of 33554432 bytes exhausted (tried to allocate 2348617 bytes) in /home3/xxx/public_html/wp-includes/plugin.php on line xxx
However, this memory limit is defined by your web host company and if the memory limit of your website is limited to a minimum of 32MB, it is quite enough size for any plugins and theme.
How to find PHP Memory Limit information on WordPress
Check the below snapshot where you can find the PHP memory limit of your website. you can easily check this out by following the path: Tool > Site Health, clicking on info tab, and navigating to Server section.
Note: If your file size is more than 32MB, you might try to use compression of that file. Because a less memory file consumes less bandwidth and makes the website faster.
Suggested: How to install and Setup WordPress in cPanel
What is the maximum file upload limit in WordPress?
Maximum file upload limit refers to the largest file size that can easily be uploaded to WordPress. If the uploaded file size is greater than the memory limit, it throws “WordPress allowed memory size exhausted”.
You can find that memory limit by login into your WordPress dashboard and navigating to Media > Add-media. You will get the maximum file upload size.
Steps to Increase PHP Memory Limit:
There are 3 basic steps that you can use to increase PHP memory limit for your WordPress website.
Note: Before updating or changing your website, it is better to backup your website.
Now let’s start!
Edit in wp-config.php file
Firstly you can try by editing the wp-config.php file. This file is located in the root folder of your website.
Next, you need to open that wp-config.php file and add the following text before the line stating “ That’s all, stop editing! Happy blogging.”
define( 'WP_MEMORY_LIMIT', '256M' );
Now, save that file and try to upload those files on WordPress and check whether that fatal error is coming or not. and you can also check the server status on the Tools section on WordPress menu.
Edit in php.ini file
If updating the wp-config.php file can not modify the file size, you may try to edit the php.ini file located in your shared hosting Cpanel section. That can help to increase PHP memory limit of your website.
Open php.ini and change the value of memory_limit.
Note: Please remember while uploading memory_limit, the value of memory_limit should be the biggest value, while upload max file size should be lower and post max size should be median.
After changing that file save php.ini and check in your WordPress whether it has been updated or not.
Edit in .htaccess file
Editing the .htaccess file is the last option to modify memory_limit of your WordPress. Most of the time .htaccess file was hidden in the root folder and you have to unhide it before editing on .htaccess file.
Make the following changes or add the following codes in your .htaccess file.
php_value memory_limit 256M php_value upload_max_filesize 24M php_value post_max_size 32M
Now save the file and try to upload those files in your WordPress and now it should work fine with throwing an error.
Hope, you are able to increase PHP memory limit by following those steps. If you are not able to fix that fatal error and memory file size has not increased, you have to connect with your web hosting service provider. Some web hosts do not allow the user to change these configurations. So, you need to inform your web hosting provider to modify those configurations at their end.
Few troubleshooting guides you should check out:
- Fix: Your site is running an insecure version of PHP – Updating PHP Version on WordPress
- Fix Error ‘Sorry, this file type is not permitted for security reasons’ on WordPress
- Resolve Warning: htmlspecialchars (): charset `UTF-7′ not supported, assuming utf-8
But if they do not agree with you for increasing the memory file size, you need to change your web hosting for better scalability.