How To Fix Allowed Memory Size of Bytes Exhausted in cPanel
⚠️ Fixing “Allowed Memory Size of Bytes Exhausted” in cPanel
This PHP error happens when a script consumes more memory than what is allowed by the server configuration.
Example error message:
🔍 Why This Happens
-
The
memory_limitin PHP is set too low. -
Large files (images, datasets, backups) consume extra memory.
-
Too many WordPress/Drupal plugins installed.
-
Poorly optimized PHP code or memory leaks.
🛠️ Solutions
1. Increase PHP Memory Limit
Option A: Edit php.ini (root or local account)
-
Open
php.ini. -
Find (or add) this line:
-
Save and restart Apache/LSAPI if needed.
Option B: Edit .htaccess (in site root)
Add this line:
Option C: Use cPanel’s MultiPHP INI Editor
-
Log into cPanel.
-
Go to Software → MultiPHP INI Editor.
-
Select your domain.
-
Set:
-
Save changes.
2. Deactivate Unused Plugins (WordPress-specific)
-
In File Manager, go to:
-
Rename the
pluginsfolder →plugins-old. -
Create a new empty folder named
plugins. -
Reload the site.
-
If it works → issue is plugin-related.
-
Restore the original folder and enable plugins one by one.
-
3. Optimize PHP Code
-
Free memory with
unset()after using large variables: -
Use pagination instead of loading large datasets at once.
-
Compress/resize images before upload.
💡 Additional Tips
-
Monitor usage with
top,htop, or cPanel Resource Usage. -
Limit memory-hogging cron jobs.
-
Keep your CMS/plugins/themes updated.
-
Always back up before applying changes.
✅ After increasing memory and optimizing, reload the site — the error should disappear.
Share
What's Your Reaction?
Like
0
Dislike
0
Love
0
Funny
0
Angry
0
Sad
0
Wow
0
