Configuring Memory Limits

This page describes how to set memory limits.

Understanding memory usage

Cloud Run container instances that exceed their allowed memory limit are terminated.

The following count towards the available memory of your container instance:

  • running the application executable (as the executable must be loaded to memory)
  • allocating memory in your application process
  • writing files to the filesystem

The size of the deployed container image does not count towards the available memory.

Setting and updating memory limits

By default, the memory allocated to each container instance of a revision is 256MiB.

Like any configuration change, setting an memory limits leads to the creation of a new revision. Subsequent revisions will also automatically get this memory limit unless you make explicit updates to change it.

You can set memory limits using the GCP Console or the gcloud command line when you create a new service or deploy a new revision:


  1. Go to Cloud Run

  2. Click CREATE SERVICE if you are setting memory limits on a new service you are deploying to. If you are setting limits on an existing service, then click on the service, then click DEPLOY NEW REVISION.



  4. Select the desired memory size from the dropdown list.

  5. Click Create or Deploy.

Command line

You can update the memory allocation of a given service by using the following command:

gcloud beta run services update [SERVICE] --memory [SIZE]

Replace [SERVICE] with the name of your service and [SIZE] with the desired memory size. The format for size is a fixed or floating point number followed by a unit: G, M, or K corresponding to gigabyte, megabyte, or kilobyte, respectively, or use the power-of-two equivalents: Gi, Mi, Ki corresponding to gibibyte, mebibyte or kibibyte respectively.

  • When deploying to Cloud Run, the maximum amount of memory is 2 gibibyte (2Gi).

  • When deploying to Cloud Run on GKE, the maximum amount of memory is limited by the configuration of your GKE cluster.

You can also set memory limits during deployment using the command:

gcloud beta run deploy --image[PROJECT-ID]/[IMAGE] --memory [SIZE]


  • [PROJECT-ID] with your GCP project ID.
  • [IMAGE] with the name of your image.
  • [SIZE] with the values described above.

Optimizing memory

The peak memory requirement for a service can be found using the following: (Standing Memory) + (Memory per Request) * (Service Concurrency)


  • If you raise the concurrency of your service, you should also increase the memory limit to account for peak usage.

  • If you lower the concurrency of your service, consider reducing the memory limit to save on memory usage costs.

For more guidance on minimizing per request memory usage read Development Tips on Global Variables.



Cloud Run Documentation