Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Memory limit exceeded

I am using Google Apps Script to create documents based on a template and some data stored in a spreadsheet. It was previously working well but recently (without having changed any code) I started getting the below error during a "google.script.run" call from a very simple HTML sidebar:

Execution failed: Memory limit exceeded

The error occurs during the copying process - it seems to occur at slightly different places each time the script is run.

I don't see any references to memory limits in the apps script quotas and a general Google search doesn't seem to find anything.

Can anyone shed some light on this and how to determine the limit/what is holding most of the memory/increase the limit if possible?

like image 200
Matthew Thorne Avatar asked Aug 07 '17 00:08

Matthew Thorne


1 Answers

Check the methods that you're using to get the data ranges.

i.e. if you use sheet.getRange(A:X) it'll get all the rows in the sheet, even the empty ones (probably in the order of tens of thousands, or even hundreds of thousands). It's a better option to use the getDataRange method, which get the last column and last row with data.

like image 188
moy2010 Avatar answered Oct 02 '22 15:10

moy2010