14+ years building on WordPress / Replies in under 5 hours
WordPress 1 min read · Updated July 2026

How to increase memory_limit in WordPress?

AK
Ajay Khandal
WordPress Developer
TL;DR

If your site throws a "fatal error: allowed memory size exhausted" message, it's because a plugin needs more memory than WordPress's default 32MB limit. The fix is to open wp-config.php and add the line define('WP_MEMORY_LIMIT', '64M') just above the "stop editing" comment, bumping it to 128M or 256M if 64MB isn't enough. This is the fastest, most reliable way to resolve memory-exhausted errors without touching server-level PHP settings.

This problem comes because some plugins need more memory_limit to run in our website and errors seem like —

Fatal error: the Allowed memory size of 33554432 bytes exhausted (tried to allocate 2348617 bytes) in /home4/xxx/public_html/wp-includes/plugin.php on line xxx

By default memory limit is 32mb. The best way to increase this limit is by using wp-config. This is one of the shortest and best ways to do it.

  1. Open wp-config.php in the editor, which is placed in your root folder.
  2. Find this line:
    /* That's all, stop editing! Happy blogging. */
  3. Paste this line below it:
    define('WP_MEMORY_LIMIT', '64M');

This will set the memory limit to 64mb. If you need more than this, you can change it to 128M or 256M depending on your requirement.

Memory limits are just one resource constraint to watch — if the site is also slow under load, comparing caching plugins in WP Rocket vs W3 Total Cache vs LiteSpeed is a natural next step.

AK

Written by Ajay Khandal

WordPress Developer — building, fixing and speeding up WordPress sites.

Work with me →