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

查询数据库时RAM占用过高引发5XX错误排查求助

问题:WordPress+LearnPress后台频繁出现内存耗尽导致的500错误

我运营的网站搭载WordPress及LearnPress LMS插件已一年,近1-2个月后台随机出现500错误,且频次逐渐增加。

错误日志详情

1. wp-db.php内存耗尽错误

错误信息:/wp-includes/wp-db.php第2128行:Allowed memory size of 536870912 bytes exhausted (tried to allocate 4096 bytes)
对应代码段:

// Return number of rows affected.
$return_val = $this->rows_affected;
} else {
    $num_rows = 0;
    if ( $this->use_mysqli && $this->result instanceof mysqli_result ) {
2128        while ( $row = mysqli_fetch_object( $this->result ) ) {
                $this->last_result[ $num_rows ] = $row;
                $num_rows++;
            }
    } elseif ( is_resource( $this->result ) ) {
        while ( $row = mysql_fetch_object( $this->result ) ) {
            $this->last_result[ $num_rows ] = $row;
            $num_rows++;
        }
    }

2. option.php内存耗尽错误

错误信息:/wp-includes/option.php第295行:Fatal error: Allowed memory size of 536870912 bytes exhausted (tried to allocate 41943040 bytes)
对应代码段:

$alloptions = array();
foreach ( (array) $alloptions_db as $o ) {
295     $alloptions[ $o->option_name ] = $o->option_value;
}

已尝试但无效的方案

  • 提升PHP内存限制
  • 迁移至VPS服务器
  • 绕过Cloudflare
  • 禁用所有插件
  • 更新/降级PHP、WordPress及插件版本
  • 回滚至1个月前的站点备份

当前推测

推测是数据库查询操作引发大量内存占用,但无法定位具体根源,希望找到排查和解决的方法。

内容的提问来源于stack exchange,提问作者Geekobit

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.08.25 20:27:18