Confirmed users
446
edits
(update for newer code -- this is a guess, so it might be wrong) |
|||
| Line 19: | Line 19: | ||
The cycle collector debugging code can be enabled by uncommenting the <code>#define DEBUG_CC</code> lines in '''both''' <code>xpcom/base/nsCycleCollector.h</code> and <code>xpcom/glue/nsCycleCollectionParticipant.h</code>. | The cycle collector debugging code can be enabled by uncommenting the <code>#define DEBUG_CC</code> lines in '''both''' <code>xpcom/base/nsCycleCollector.h</code> and <code>xpcom/glue/nsCycleCollectionParticipant.h</code>. | ||
The cycle collector debugging code relies on being told that cycle-collected objects are expected to be garbage. This is done through the functions <code>nsCycleCollector_DEBUG_shouldBeFreed</code> and <code>nsCycleCollector_DEBUG_wasFreed</code>. When using the cycle collector debugging, it may be helpful to add additional calls to these functions (or maybe even remove some of the existing ones if they add noise). It may also be useful to look only at the cycle collection that happens at shutdown (which can be done by surrounding the call to <code>ExplainLiveExpectedGarbage</code> in <code>nsCycleCollector::Collect</code> with <code>if ( | The cycle collector debugging code relies on being told that cycle-collected objects are expected to be garbage. This is done through the functions <code>nsCycleCollector_DEBUG_shouldBeFreed</code> and <code>nsCycleCollector_DEBUG_wasFreed</code>. When using the cycle collector debugging, it may be helpful to add additional calls to these functions (or maybe even remove some of the existing ones if they add noise). It may also be useful to look only at the cycle collection that happens at shutdown (which can be done by surrounding the call to <code>ExplainLiveExpectedGarbage</code> in <code>nsCycleCollector::Collect</code> with <code>if (origTryCollections > 1)</code>. | ||
When this code is enabled, it prints an explanation of what is keeping alive any objects that are expected to be garbage but are not collected. This means it will print information about what objects from which they are reachable have reference counts that the cycle collector does not know about; you can then debug the leak starting from these objects. It also prints the path from the object keeping this alive to the closest object that it is keeping alive, and if the object keeping things alive is a JS object, it prints all the objects from which that object is reachable. | When this code is enabled, it prints an explanation of what is keeping alive any objects that are expected to be garbage but are not collected. This means it will print information about what objects from which they are reachable have reference counts that the cycle collector does not know about; you can then debug the leak starting from these objects. It also prints the path from the object keeping this alive to the closest object that it is keeping alive, and if the object keeping things alive is a JS object, it prints all the objects from which that object is reachable. | ||