Do I have a memory leak?

Use Chrome's DevTools to find out if your Ember app is leaking memory.

Summary

Memory leaks are hard to track down in Ember applications. They often happen slowly over long periods of time, which means you need to be using the application for a few hours to even notice them.

We can use Chrome's DevTools to run a memory profile by visiting the Performance tab and clicking the record button.

This graph shows us how our application's memory grows over time.

Ember memory profiler

In order to find out if our application is leaking, we can use our existing test suite.

After each test run we would expect our Ember application to be cleaned up and released from the browser's memory. However, if we can see the Ember app in memory when the tests are done, we know we have a leak.

First, we'll run the test suite and take a heap snapshot using the memory tab in DevTools. Next, we'll search the heap for Ember's container. The presence of the container means the application was not able to be released from memory.

Ember memory heap

We can filter our test runner to a specific set of tests and check the heap. This will tell us which parts of the application are leaking memory.

Questions?

Send us a tweet:

Or ask us in Inside EmberMap, our private Slack workspace for subscribers.