You may not always appreciate the Chrome Developer Tools, but they are your best option at the moment. It's all about using them smartly.
For example, if you need to check if a certain action in your application is causing memory leaks, like rendering a view or fetching new data, let's call it the Action
.
To determine how much memory is being reserved and retained, you first need to establish a baseline and eliminate any extra noise. Here are three steps to help you achieve that:
Warm-up
Open your application (visit your website). Perform Action
. Take a heap snapshot. This initial snapshot will be discarded, but it helps clean things up and ensure no interference with your measurable data.
Baseline
Repeat the Action
three times. Take a heap snapshot after each run. These snapshots create the baseline for comparing memory usage. Doing the Action
multiple times accounts for any slight variations in execution. Try to perform the Action
consistently each time.
Measurement
Again, repeat the Action
three times and take another heap snapshot.
You now have three snapshots. The interesting part lies in the Summary of Objects allocated between snapshots 2 and 3, as well as the difference shown in Comparison from Snapshot 3 to Snapshot 2. Look for these details in the bottom/status bar of the Profiles view.
The data captured between the Baseline and Measurement snapshots reveals the true memory profile for the Action
. Understanding this data correctly is key. Google's documentation on the profiler can guide you through the process: Google's documentation on the profiler.
At present, there doesn't seem to be a better alternative or tool available. If there is one out there, I'd be interested to learn about it.