0

I am attempting to do 25 or so text replacement updates via the batchUpdate() function for Google Slides in PHP.

I continue to receive the following error:
Allowed memory size of 536870912 bytes exhausted (tried to allocate 260050944 bytes)

Here is a basic rundown of what I'm doing:

// $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' => ''
        ],
    ]);
}

I can do up to 2 requests in the update, otherwise I get a memory error. I have logged my memory usage before and after creating the Google_Service_Slides_BatchUpdatePresentationRequest object using memory_get_usage(), and it appears I am not using an enormous amount.

As far as I can tell, the batchUpdate request is either too large when sending, or the response is too large when returned.

Any help would be amazing!

Gurnzbot
  • 3,742
  • 7
  • 36
  • 55
  • OK whos giving this error your server or google. I find it hard to beleave it would be google. Whats the full error stack trase – Linda Lawton - DaImTo Sep 10 '20 at 18:04
  • Does this answer your question? [Allowed memory size of 262144 bytes exhausted (tried to allocate 24576 bytes)](https://stackoverflow.com/questions/16175153/allowed-memory-size-of-262144-bytes-exhausted-tried-to-allocate-24576-bytes) – Linda Lawton - DaImTo Sep 10 '20 at 18:05

0 Answers0