Why am I getting an out-of-memory error in my service?

Last updated: June 30, 2025

Context

Out of memory errors occur when your application attempts to use more memory than its allocated limits, causing the cluster to restart the service. This can happen due to improper load handling or memory leaks in your application, for example.

Answer

There are two approaches to addressing out-of-memory errors:

Temporary Solution

You can increase the memory allocation for your service:

  1. Navigate to the Resources tab of your service

  2. Increase the memory allocation for your application

Recommended Long-term Solution

While increasing resources provides immediate relief, it's not the most efficient long-term solution. Instead:

  1. Profile your application to identify memory usage patterns

  2. Analyze how your application behaves under different load conditions

  3. Identify which processes consume the most resources

  4. Fix any memory leaks in your code

Note: Out-of-memory errors can occur very quickly, so they might not always be visible in the Metrics tab due to metric sampling rates.