# Understanding memory usage in your application

> High memory usage isn't necessarily a problem - applications often use available memory for caching to improve performance, and brief spikes during peak times are normal. You should only consider upgrading when memory consistently stays above 80%, your application crashes with exit code 137, or you experience performance issues combined with high memory usage.

Understanding memory usage in your application
----------------------------------------------

### How memory statistics work

Your application's memory usage is monitored in real-time and displayed in the statistics tab. The system checks memory consumption every 5 seconds, giving you an up-to-date view of how your application is performing.

### Reading the memory indicators

Memory usage is shown with three visual elements:

- **Percentage**: Shows how much of your allocated memory is currently being used (e.g., "45.2%")
- **Progress bar**: A visual representation of memory consumption with color coding
- **Actual usage**: Displays the exact amount used versus allocated (e.g., "512Mi / 1Gi")

### Understanding the color codes

The memory indicator uses traffic light colors to help you quickly assess usage:

- **Green (0-59%)**: Your application has plenty of memory available. This is the ideal operating range.
- **Yellow (60-79%)**: Memory usage is moderate. Your application is functioning well but you should monitor for increases.
- **Red (80%+)**: High memory usage. While your application may still run fine, you're approaching the limit.

### Is high memory usage always a problem?

**No, high memory usage isn't necessarily bad.** Here's why:

- Applications often use available memory for caching to improve performance
- Memory usage naturally fluctuates based on user activity and workload
- Brief spikes to 80-90% during peak times are normal
- Your application has a 10% buffer above its guaranteed memory for handling temporary spikes

### When should you consider upgrading?

Look for these signs that indicate you need more memory:

- **Consistent red indicators**: If memory stays above 80% for extended periods
- **Application crashes**: If your application restarts with exit code 137, it ran out of memory
- **Performance issues**: Slow response times combined with high memory usage
- **Multiple services at high usage**: When both your application and database show high memory consumption

### How memory allocation works

When you select memory for your application:

- Your application is guaranteed 90% of the selected amount at all times
- The remaining 10% serves as a buffer for temporary spikes
- Memory is automatically calculated based on CPU selection
- Each instance gets the full memory allocation when running multiple instances

### Taking action

If you determine you need more memory:

1. Go to the **Resources** tab in your application settings
2. Adjust the CPU slider (memory increases automatically with CPU)
3. Review the updated monthly cost
4. Save your changes to apply the new allocation

**Pro tip**: Monitor your application's memory patterns over a week to understand its true needs before upgrading. Short-term spikes during deployments or batch processes are normal and don't require permanent resource increases.
