Main menu

Memory size exhausted

FAQ: How do I fix memory limit errors?

You may see this error when running Sync operations or creating templates:

Error: Allowed memory size of XXX bytes exhausted

This is PHP telling you that the maximum amount of memory it's allowed has been reached. String extraction is the most memory intensive operation that Loco Translate performs. If it encounters a particularly large PHP file then the momentary memory usage may spike wildly.

Your options here are to either raise the limit, or avoid such a limit being reached in the first place. The latter is preferred when possible, but may be harder to achieve.

Avoid the limit

There's no way to avoid the amount of memory Loco Translate needs to process a large PHP file, but you may find you can avoid it altogether.

  1. Skip files over a maximum size
    Loco Translate skips PHP files larger than 100K. This is the default, but you can lower the amount in the plugin settings. Skipping large files will avoid memory spikes, but check that all the files over this size don't actually contain strings you need.

  2. Skip specific files
    Loco Translate allows you to exclude specific files from source code scanning. If you have one massive rogue file that contains no translatable strings, you should configure your bundle to ignore it.

  3. Don't extract strings
    If you're not the developer of a bundle, you ideally should not be in a position to be extracting strings at all. Authors should provide you with a translation template. With a template file configured there will be no source code scanning and Sync operations will be fast and low on memory.

Raise the limit

This is a complicated topic and the precise details will depend on many factors about your server and your WordPress installation.

Loco Translate observes the memory limit configured for PHP. If you need to raise this you should contact your web hosting provider, or whoever provides you with technical support.

Loco also observes WordPress's WP_MAX_MEMORY_LIMIT. It will use this limit if possible, but generally the PHP memory limit is set deliberately to avoid being broken. Bursting it this way is not guaranteed to succeed and also requires WordPress 4.6 or higher.