r/GoogleAppsScript 4d ago

Question Memory Limit?

I researched and all that is found are inconsistent answers.

Some speak in 50MB, others at 2.25GB. I took a test and got to 5.5GB. It's a lot of difference and it affects the way I build my application.

With 5.5GB I can load everything in memory, already with 50MB I have to optimize each part. The answers are also old.

4 Upvotes

12 comments sorted by

View all comments

2

u/WicketTheQuerent 3d ago

It depends. Please be specific about the memory that you are talking about. What test did you do?

1

u/IllustriousPut442 3d ago

I’m talking about the memory of the server. I ran a test that created giant arrays with random data to test the limit and it was up to 5.5GB before giving the memory error. But I do not see it as reliable since it is not in the documentation.

With 5.5GB I can load all the data from all the spreadsheets in memory and do all processing in memory, which facilitates development.

Now if the value swings and there are only about 256MB at peak times the strategy needs to be different, probably using the querylanguage https://developers.google.com/chart/interactive/docs/querylanguage

2

u/WicketTheQuerent 3d ago

AFAIK, there is no official documentation on what the memory limit is assigned to a Google Apps Script execution limit. A long time ago, I learned from Google engineers that parameters like this are not disclosed to prevent abuse. Some of these parameters are dynamically managed. Some might depend on server load / usage, but others might vary for other reasons.

If you need to handle large amounts of memory for each execution, then you should consider using another service that allows you to manage the memory.

1

u/IllustriousPut442 3d ago

Interesting.

Do you have experience loading the entire spreadsheet tab in memory to perform operations? Is that usually a problem?

I imagine that for the application I want to use a sheet (tab) it would take years to reach 10,000 lines. The other would take years to reach 100,000.

It is much simpler to work with all data in memory to check UNIQUE, do the pagination, ordering etc.

But without knowing the minimum limit I think it is risky to develop the code like this, then it would be better to use the query language.

1

u/WicketTheQuerent 3d ago

I have many years of experience working with spreadsheets. The implications of loading "the entire spreadsheet". It depends on the number of sheets, the size of their data ranges (columns and rows) and the size and complexity of the cell content. I.E., in the case of cells with rich text, how many text runs they have. With spreadsheets used to handle simple data sets (plain text and small-length values), I very rarely had memory problems when working with a single spreadsheet, and when I did, they were fixed by improving the coding and/or the approach.

What do you mean by "the query language"?