Configure memory and vCPU limits (1st gen)

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 are shown in the following table:

Memory CPU
128MB .083 vCPU
256MB .167 vCPU
512MB .333 vCPU
1024MB .583 vCPU
2048MB 1 vCPU
4096MB 2 vCPU
8192MB 2 vCPU
Not available 4 vCPU
Not available 8 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 a function 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 Google Cloud console:

  1. Go to the Cloud Functions Overview page in the Google Cloud 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.
  6. Click Next.
  7. Click Deploy.