Diagnosing and resolving out-of-memory errors and automatic restarts
Last updated: September 19, 2025
Out-of-memory errors can cause automatic application restarts, leading to performance issues and potential downtime. Understanding how these errors occur and how to address them is crucial for maintaining application stability.
Understanding out-of-memory restarts
When your application exceeds its configured memory limits, the cluster automatically restarts the affected container. This is different from manual restarts triggered through the Deploy button - these automatic restarts happen when your application violates its memory allocation, not due to cluster-wide memory availability issues.
During these restarts, API requests should automatically route to other healthy instances in your cluster. However, you may notice increased response times and temporary performance impacts until the restarted instance recovers and rejoins the cluster.
Why memory spikes don't appear in metrics
Memory spikes that cause out-of-memory errors often happen too quickly to be captured in standard metrics views. This occurs because:
Metrics sampling intervals may miss rapid memory consumption spikes
The restart happens before the spike can be recorded in your monitoring dashboard
Average memory usage may appear normal despite brief but critical peaks
Instead of relying solely on metrics, monitor these errors through dashboard notifications and application logs to get a complete picture of memory-related issues.
Common causes of memory issues
Out-of-memory errors typically indicate one of two problems:
Memory leaks in application code - Objects not being properly garbage collected, causing gradual memory accumulation
Poor load handling - Application unable to manage high traffic volumes or large data processing tasks within memory constraints
Resolving memory-related restarts
To address recurring memory issues:
Profile your application - Use memory profiling tools to identify where your application consumes the most memory
Optimize based on usage patterns - Analyze your application's memory consumption patterns and optimize accordingly
Review memory limits - Ensure your configured memory limits align with your application's actual requirements
Implement proper error handling - Add safeguards to prevent memory-intensive operations from overwhelming your application