You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

WordPress+Elementor Pro存页报500错误:formatting.php内存溢出求助

Fixing WordPress Elementor Pro 500 Error (Out of Memory) When Saving Pages

Hey there, sorry to hear you're stuck with this frustrating 500 error when saving Elementor pages—especially since the page isn't even that large. Let's break down the core issue and walk through actionable fixes based on your error logs and setup.

First, the root cause is clear from your logs: a PHP Out of Memory error happening at the preg_replace line in the normalize_whitespace() function in formatting.php. Even though you've set WP_MEMORY_LIMIT to 128M and your host (Strato) confirms that's the upper limit, there are still several ways to tackle this.

1. Verify PHP's Global Memory Limit

The WP_MEMORY_LIMIT setting controls memory for WordPress's admin area, but PHP itself has a separate memory_limit configuration that might be lower than 128M. Here's how to check and adjust it:

  • Create a simple phpinfo.php file in your WordPress root directory with this code:
    <?php phpinfo(); ?>
    
    Access it via your browser and look for the memory_limit value. If it's less than 128M, adjust it:
    • If your host allows editing .htaccess, add this line at the top:
      php_value memory_limit 128M
      
    • If you can edit php.ini (via cPanel or your host's dashboard), set:
      memory_limit = 128M
      
    • If neither works, reach out to Strato support to confirm they’ve applied the 128M limit globally for your account.

2. Optimize Elementor's Memory Usage

Elementor Pro can be memory-intensive even on small pages. Try these steps to reduce its footprint:

  • Clear Elementor Cache: Go to Elementor > Tools > General and click "Clear Cache" and "Regenerate CSS". This removes old, unnecessary data that might be clogging memory.
  • Disable Unused Add-ons: If you have Elementor extensions or third-party add-ons installed, disable any you aren’t actively using—each adds overhead.
  • Simplify the Problem Page: Temporarily remove elements (like large text blocks, galleries, or dynamic content) and try saving incrementally. This helps pinpoint if a specific element is triggering the memory spike in normalize_whitespace().

3. Replace the Memory-Heavy normalize_whitespace() Function

The error occurs at the preg_replace line, which uses an array-based regex that can eat up memory for certain strings. Override this function with a more memory-friendly version in your theme’s functions.php (use a child theme to avoid losing changes on updates):

function normalize_whitespace( $str ) {
    $str = trim( $str );
    $str = str_replace( "\r", "\n", $str );
    
    // Split regex operations to reduce memory load
    $str = preg_replace('/\n+/', "\n", $str);
    $str = preg_replace('/[ \t]+/', ' ', $str);
    
    return $str;
}

Splitting the original array regex into two separate calls reduces memory usage for large strings.

4. Check for Host-Specific Restrictions

Even if Strato advertises a 128M limit, shared hosts often impose additional constraints like process memory caps or execution time limits. Reach out to their support and ask:

  • Is the 128M limit applied to individual PHP processes, or is it a shared account-wide limit?
  • Are there any other restrictions (like max execution time) that might be contributing to the error?

Hopefully one of these steps gets you past the 500 error so you can save your pages smoothly!

内容的提问来源于stack exchange,提问作者Felix Mohr-Fernandt

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.28 06:41:06