Google Slides API批处理更新内存已耗尽

问题描述

我正在尝试通过batchUpdate()函数PHP中的Google幻灯片进行25次左右的文本替换更新。

我继续收到以下错误
Allowed memory size of 536870912 bytes exhausted (tried to allocate 260050944 bytes)

这是我正在做的事情的基本摘要

// $report is an array of key-values that are going to be replaced
foreach ($report as $key => $value) {
    $requests[] = createPresentationReplacements($key,$value);
}

$batch_request = new Google_Service_Slides_BatchUpdatePresentationRequest([
    'requests' => $requests
]);

// Assume $client is correctly set and $presentation_id is correct as well
$slide_service = new Google_Service_Slides($client);

// Dies here!
$slide_service->presentations->batchUpdate($presentation_id,$batch_request);

function createPresentationReplacements($key,$value)
{
    return new Google_Service_Slides_Request([
        'replaceAllText' => [
            'containsText' => [
                'text' => '{{' . $key . '}}','matchCase' => true,],'replaceText' => $value,'fields' => ''
        ],]);
}

在更新中,我最多可以执行2个请求,否则会出现内存错误。在使用Google_Service_Slides_BatchUpdatePresentationRequest创建memory_get_usage()对象之前和之后,我已经记录了我的内存使用情况,看来我没有使用太多。

据我所知, batchUpdate 请求在发送时太大,或者在返回时响应太大。

任何帮助都会很棒!

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)