Memory limits

You can provision Cloud Functions with different amounts of memory to control the limit on how much memory a function can use. The amount of allocated memory you choose corresponds to an amount of allocated CPU for your function. Available memory and CPU tiers for Cloud Functions (1st gen) and Cloud Functions (2nd gen) are shown in the following table:

Memory (1st gen) Memory (2nd gen) CPU
128MB 128 MiB .083 vCPU
256MB 256 MiB .167 vCPU
512MB 512 MiB .333 vCPU
1024MB 1 GiB .583 vCPU
2048MB 2 GiB 1 vCPU
4096MB 4 GiB 2 vCPU
8192MB 8 GiB 2 vCPU
Not available 16 GiB 4 vCPU

By default, the memory allocated for a function is 256MB or 256 MiB depending on the Cloud Functions product version.

See Cloud Functions Pricing for information about costs associated with memory and CPU allocations.

Set a memory limit

You can set a function's allocated memory at deployment using the Google Cloud CLI or the Google Cloud console.

gcloud

If you are deploying using the gcloud CLI, use the --memory flag:

gcloud functions deploy YOUR_FUNCTION_NAME --memory=MEMORY_LIMIT ...

Console

To set the allocated memory during function creation in the console:

  1. Go to the Cloud Functions Overview page in the console.
  2. Click Create function.
  3. Fill in the required fields for your function.
  4. Expand the Runtime, build... section at the end of the page and click the Runtime tab.
  5. In the Memory allocated field, select an amount of memory.