How much memory does Google allot to Apps Script programs/projects?

1,637 views
Skip to first unread message

dimud...@gmail.com

unread,
Sep 22, 2021, 10:03:57 AM9/22/21
to Google Apps Script Community
I've been testing the limits of the platform, loading a 200 MB file from Drive into a GAS application using Drive V3 API partial downloads and UrlFetchApp.fetchAll()

I managed to load the 200MB file in chunks of 50MB. Then I stitch/join those chunks together, where each chunk is a sequence of bytes from a blob . 

All is well up to that point.

When I attempt to process the bytes (Uint8Array) using a 3rd party Javascript library from NPM I end up with an "Out of Memory" error. It works for smaller files (tested with 77MB and 100MB files) but I seem to be hitting a limit at 200+MB.

So now I'm curious. Does anyone know how much memory(think RAM) Google allots to GAS programs running in the cloud? 

Tanaike

unread,
Sep 22, 2021, 10:14:14 PM9/22/21
to Google Apps Script Community
Unfortunately, I have never checked the correct limitation size of the memory. But, in my case, when the memory error occurs, I noticed that there are most cases that the array is created several times. At that time, at first, an array is created, and when I want to use the other array, clear the existing array, and then, use the cleared array. And also, when the values are put and process in an array in the loops, check each element by "slice". By this, it seems that the memory can be saved. By this, I could avoid the memory error with Google Apps Script. If this was not useful information for your situation, I apologize.

dimud...@gmail.com

unread,
Sep 24, 2021, 9:28:04 AM9/24/21
to Google Apps Script Community
That was insightful. Thank you Tanaike.

I've been running some more experiments to find the upper-bound on memory in GAS. I've been creating ArrayBuffer instances (V8 runtime) of various sizes to see how far I can push it. So I've tried the following:

function createBuffer() {
    let buffer = new ArrayBuffer(2415919104); // 2.25GB buffer
}

I'm able to generate a 2.25 GB buffer (byte array in memory). When I try for 2.5GB I get the following error:
The JavaScript runtime exited unexpectedly.

So the limit probably lies somewhere between 2.25 and 2.5 gigabytes.

Tanaike

unread,
Sep 25, 2021, 7:38:35 AM9/25/21
to Google Apps Script Community
Thank you for the information. I think that it is useful information.

Jonathan Butler

unread,
Nov 19, 2021, 6:13:59 PM11/19/21
to google-apps-sc...@googlegroups.com
I'm not sure why I went down this rabbit hole, but today I experimented and found that the limit for sending data with google.script.run was 52428700 bytes. A single byte more and it hangs and eventually hits a document too large error.

On Sat, Sep 25, 2021 at 6:38 AM Tanaike <kanshi...@gmail.com> wrote:
Thank you for the information. I think that it is useful information.

--
You received this message because you are subscribed to the Google Groups "Google Apps Script Community" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-apps-script-c...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/google-apps-script-community/6573c532-7394-4bb8-aed8-04d44cb801ccn%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages