Three Memory Leak Patterns
Normal Memory Usage
In a typical application, memory consumption should increase when the application boots and then stabilize. This pattern will repeat every time the application is deployed.
Memory
^
|
| ███████████████████████ ████████████████████
| █████████████████████████████ ██████████████████████████
| █████████████████████████████████████████████████████████ > Time
Boot Stable Runtime Deploy Stable Runtime
Gradual Leak
In an application with a gradual memory leak, the memory usage will increase sporadically. This is usually due to specific code paths that are only executed sporadically, causing memory leaks. This pattern looks like a very gradual increase in memory over time that never plateaus and gets reset every time an application is deployed. This is a challenging memory leak to identify because frequent deploys can mask it.
Memory
^
|
| ███████████ ████████████
| █████████████ ███████████████
| ██████████████████ ██████████████████
| ██████████████████████████████ ███████████████████████████
| ██████████████████████████████ ███████████████████████████
| ███████████████████████████████████████████████████████████████ > Time
Boot Gradual Memory Growth Deploy Gradual Memory Growth
Spiky Memory Leak
A memory leak that causes a dramatic spike in memory will often cause the application to churn, meaning it boots up, memory increases continually, it hits the limit, it runs out of memory, and reboots. This happens over and over and over. These are very easy to identify memory leaks, although the source may be challenging to locate.
Memory
^
|
| ████ ████
| ███████ ███████
| ██████████ ██████████
| █████████████ █████████████
|████████████████ ████████████████
|██████████████████████████████████████████████ > Time
Boot |Rapid Growth | Repeat
CRASH!