Confirmed users
620
edits
Amccreight (talk | contribs) (add some description of how to find leaks using the CC dump) |
Amccreight (talk | contribs) |
||
Line 140: | Line 140: | ||
To automatically generate a cycle collector dump, set gAlwaysLogCCGraphs to true in xpcom/base/nsCycleCollector.cpp. This will make every cycle collection produce a dump. This is primarily useful for debugging shutdown leaks. | To automatically generate a cycle collector dump, set gAlwaysLogCCGraphs to true in xpcom/base/nsCycleCollector.cpp. This will make every cycle collection produce a dump. This is primarily useful for debugging shutdown leaks. | ||
To analyze a cycle collector dump, you need the scripts from [https://github.com/amccreight/heapgraph/tree/master/cc Github]. The relevant scripts are find_roots.py and parse_cc_graph.py (which is called by find_roots). Calling find_roots on a CC file with a specific object or kind of object will produce paths from rooting objects to the specified objects. To fix a leak, the next step is to figure out why the rooting object is alive. For a C++ object, you need to figure out where the missing references are from. For a JS object, you need to figure out why the JS object is reachable from a JS root. For the latter, you can use the corresponding [https://github.com/amccreight/heapgraph/tree/master/gc find_roots for JS] on the gc-edges file generated by the CC dump. | To analyze a cycle collector dump, you need the scripts from [https://github.com/amccreight/heapgraph/tree/master/cc Github]. The relevant scripts are find_roots.py and parse_cc_graph.py (which is called by find_roots). Calling find_roots on a CC file with a specific object or kind of object will produce paths from rooting objects to the specified objects. Most big leaks include an nsGlobalWindow, so that's a good class to try if you don't have any better idea. | ||
To fix a leak, the next step is to figure out why the rooting object is alive. For a C++ object, you need to figure out where the missing references are from. For a JS object, you need to figure out why the JS object is reachable from a JS root. For the latter, you can use the corresponding [https://github.com/amccreight/heapgraph/tree/master/gc find_roots for JS] on the gc-edges file generated by the CC dump. | |||
=== Leak tools for medium-size object graphs === | === Leak tools for medium-size object graphs === |