Configure memory limits for services Stay organized with collections Save and categorize content based on your preferences.
You can choose the amount of memory to provide for your Cloud Runservice. This page describes how to specify the amount of memoryavailable for your service.
Understand memory usage
Cloud Run instances that exceed their allowed memory limit areterminated.
The available memory for your instance needs to be sufficient for:
- Running the service executable, because the executable must be loaded tomemory
- Allocating memory in your service process
- Writing files to the file system
The size of the deployed container image does not affect memory that is availablefor the instance.
Set and update memory limits
You can set memory limits on Cloud Run services.By default, the memory allocated to each instance of a revision is512 MiB, and the memoryallocated for a function is 256 MiB.
Required memory when setting a CPU value
When setting a CPU value, the following memory is required:
| CPUs | Memory required |
|---|---|
| .08 vCPU | Up to 512 MiB |
| .5 vCPU | Up to 1 GiB |
| 1 vCPU | Up to 4 GiB |
| 2 vCPU | Up to 8 GiB |
| 4 vCPU | 2 to 16 GiB |
| 6 vCPU | 4 to 24 GiB |
| 8 vCPU | 4 to 32 GiB |
Maximum amount of memory
The maximum amount of memory you can configure is32 gibibyte (32 Gi).
Minimum memory
The minimum memory setting varies depending on whether you usefirst generation or second generationexecution environment:
- 128 MiB for first generation
- 512 MiB for second generation
Required roles
To get the permissions that you need to configure and deploy Cloud Run services, ask your administrator to grant you the following IAM roles:
- Cloud Run Developer (
roles/run.developer) on the Cloud Run service - Service Account User (
roles/iam.serviceAccountUser) on the service identity
If you are deploying aserviceorfunction from source code, youmust also have additional roles granted to you on your project andCloud Build service account.
For a list of IAM roles and permissions that are associated withCloud Run, seeCloud Run IAM rolesandCloud Run IAM permissions.If your Cloud Run service interfaces withGoogle Cloud APIs, such as Cloud Client Libraries, see theservice identity configuration guide.For more information about granting roles, seedeployment permissionsandmanage access.
Configure memory limits
Any configuration change leads to thecreation of a new revision. Subsequent revisions will also automatically getthis configuration setting unless you make explicit updates to change it.
For Cloud Run services, you can set memory limits using the Google Cloud console, the gcloudcommand line, or a YAML file when youcreate a new service ordeploy a new revision:
Console
In the Google Cloud console, go to Cloud Run:
SelectServices from the Cloud Run navigation menu, and clickDeploy container to configure a new service.If you are configuring an existing service, click theservice, then clickEdit and deploy new revision.
If you are configuring a new service, fill out the initial servicesettings page, then clickContainer(s), Volumes, Networking, Security to expand theservice configuration page.
Click theContainer tab.

- Select the desired memory size from theMemory dropdown list.
ClickCreate orDeploy.
gcloud
You canupdate the memory allocationof a given service by using the following command:
gcloudrunservicesupdateSERVICE--memorySIZE
ReplaceSERVICE with the name of your service andSIZE with the desiredmemory size. The format for size is a fixed or floating point number followedby a unit:G orM corresponding to gigabyte or megabyte,respectively, or use the power-of-two equivalents:Gi orMicorresponding to gibibyte or mebibyte respectively.
You can also set memory limits duringdeployment using the command:
gcloudrundeploy--imageIMAGE_URL--memorySIZE
Replace the following:
- IMAGE_URL: a reference to the container image, forexample,
us-docker.pkg.dev/cloudrun/container/hello:latest. If you use Artifact Registry,therepositoryREPO_NAME mustalready be created. The URL follows the format ofLOCATION-docker.pkg.dev/PROJECT_ID/REPO_NAME/PATH:TAG. - SIZE: the values described above.
--source instead of--image, and add--function if deploying a function.YAML
If you are creating a new service, skip this step.If you are updating an existing service, download itsYAML configuration:
gcloudrunservicesdescribeSERVICE--formatexport>service.yamlUpdate the
memoryattribute:apiVersion:serving.knative.dev/v1kind:Servicemetadata:name:SERVICEspec:template:metadata:name:REVISIONspec:containers:-image:IMAGEresources:limits:memory:SIZE
Replace the following:
- SERVICE: the name of your Cloud Run service.
- IMAGE_URL: a reference to the container image, forexample,
us-docker.pkg.dev/cloudrun/container/hello:latest. If you use Artifact Registry,therepositoryREPO_NAME mustalready be created. The URL follows the format ofLOCATION-docker.pkg.dev/PROJECT_ID/REPO_NAME/PATH:TAG. - SIZE: the desired memory size.The format is a fixed or floating point number followed by a unit:
GorMcorresponding to gigabyte or megabyte,respectively, or use the power-of-two equivalents:GiorMicorresponding to gibibyte or mebibyte respectively. - REVISION with a new revision name or delete it (if present). If you supply a new revision name, itmust meet the following criteria:
- Starts with
SERVICE- - Contains only lowercase letters, numbers and
- - Does not end with a
- - Does not exceed 63 characters
- Starts with
Create or update the service using the following command:
gcloudrunservicesreplaceservice.yaml
Terraform
To learn how to apply or remove a Terraform configuration, seeBasic Terraform commands.
Add the following to agoogle_cloud_run_v2_service resource in your Terraform configuration:resource"google_cloud_run_v2_service""default"{name="cloudrun-service-memory-limits"location="us-central1"deletion_protection=false # set to "true" in productiontemplate{containers{image="us-docker.pkg.dev/cloudrun/container/hello"resources{limits={ # Memory usage limit (per container)memory="512Mi"}}}}}Undertemplate.containers.resources.limits, replace512Mi with yourservice's desired memory limit.
Optimize memory for services
For a Cloud Run service, you can determine the peak memory requirement for a service using thefollowing:(Standing Memory) + (Memory per Request) * (Service Concurrency)
Accordingly,
If you raise the concurrency of your service, you should alsoincrease the memory limit to account for peak usage.
If you lower the concurrency of your service, consider reducing the memorylimit to save on memory usage costs.
For more guidance on minimizing per request memory usage readDevelopment Tips on Global Variables.
View memory limit settings
To view the current memory limit settings for yourCloud Run service:
Console
In the Google Cloud console, go to the Cloud RunServices page:
Click the service you are interested in to open theService detailspage.
Click theRevisions tab.
In the details panel at the right, the memory limit settingis listed under theContainer tab.
gcloud
Use the following command:
gcloudrunservicesdescribeSERVICE
Locate the memory limit setting in the returnedconfiguration.
Except as otherwise noted, the content of this page is licensed under theCreative Commons Attribution 4.0 License, and code samples are licensed under theApache 2.0 License. For details, see theGoogle Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2026-02-19 UTC.