From:  Nick Fitzgerald <nfitzgerald@mozilla.com>
Date:  04 Nov 2015 06:32:39 Hong Kong Time
Newsgroup:  news.mozilla.org/mozilla.dev.memory
Subject:  

New heap snapshots tool in the developer tools

NNTP-Posting-Host:  63.245.214.181

Hi folks!

(Jordan Santell made an announcement on the devtools mailing list[0], but I thought I'd spread the word around.)

The first iteration of the new heap snapshots memory tools landed on m-c in the middle of the last cycle and rode the train to Developer Edition with the merge.

This tool is built on top of JS::ubi::Node[1] which is an API to do analyses on the heap graph as the GC sees it, and the SavedFrame JS stack recording[2].

In this first release, the most notable feature is capturing the JS stack when objects are allocated so that you can see exactly where your retained objects are coming from. The downside is that this incurs overhead and you have to start recording allocation stacks *before* you start saving heap snapshot. You can also disect the heap into various other buckets.
This initial version is very much just getting something out the door and there is a ton more coming down the pipe. Filtering/searching and diffing snapshots are in the works at the moment. Currently, we don't take advantage of our full access to every node and edge in the heap graph. Soon, we will compute dominator trees to find "deep" size / retention as well as find the first N shortest paths from GC roots to objects of interest. We are also planning on adding support for cycle collected nodes and edges to the JS::ubi::Node graph.

You can enable the new tool by going to the settings panel of the devtools and checking the "Memory" checkbox on the left underneath "Default Firefox Developer Tools".

http://i.imgur.com/hEPTqrT.png

If you would like to use this tool for the whole runtime rather than scoped to a single tab, use the browser toolbox. Here are instructions for enabling and using the browser toolbox: https://developer.mozilla.org/en-US/docs/Tools/Browser_Toolbox

Please try it out and file bugs in the "Firefox" product and "Developer Tools: Memory" component! We want this to be a useful tool for _you_!

Thanks,

Nick