137
cloud
resource_error
ai_generated
partial
容器终止:退出代码 137(内存不足)
Container terminated: Exit code 137 (Out of Memory)
ID: cloud/gcp-cloud-run-container-crash-oom
82%修复率
87%置信度
1证据数
2023-09-05首次发现
版本兼容性
| 版本 | 状态 | 引入 | 弃用 | 备注 |
|---|---|---|---|---|
| Cloud Run (fully managed) | active | — | — | — |
| Cloud Run for Anthos | active | — | — | — |
| gcloud CLI 460.0.0 | active | — | — | — |
根因分析
Cloud Run 容器超过其分配的内存限制(默认 512 MB),导致内核 OOM 杀手终止进程。
English
Cloud Run container exceeds its allocated memory limit (default 512 MB), causing the kernel OOM killer to terminate the process.
官方文档
https://cloud.google.com/run/docs/troubleshooting#container-crash-oom解决方案
-
Increase the memory limit for the Cloud Run service: `gcloud run deploy <SERVICE> --memory=1Gi --region=us-central1`. Monitor memory usage via Cloud Monitoring and adjust accordingly. Also consider reducing concurrency: `gcloud run deploy <SERVICE> --concurrency=10` to limit simultaneous requests.
-
Profile the application to find memory-heavy operations. For Node.js, use `--max-old-space-size` flag in the Dockerfile: `CMD ["node", "--max-old-space-size=256", "app.js"]`. For Python, use `gc.set_threshold()` to tune garbage collection.
无效尝试
常见但无效的做法:
-
85% 失败
Memory leaks continue to grow unbounded; the container will eventually hit the new limit too, wasting money.
-
95% 失败
The same container image with the same memory limit will crash again under the same load.