Closed Bug 679779 Opened 9 years ago Closed 9 years ago

Add #define to always log the cycle collector graph

Categories

(Core :: XPCOM, defect)

defect
Not set

Tracking

()

RESOLVED FIXED
mozilla9

People

(Reporter: mccr8, Assigned: mccr8)

Details

Attachments

(1 file, 2 obsolete files)

For leak finding purposes it is often useful to set the cycle collector to always produce a cycle collector log.  Thanks to all of the listener code, this capacity is present even in a non-DEBUG_CC build, but getting it to actually trigger all of the time requires a little bit of fussing with the code in nsCycleCollector.cpp.

This patch adds a new macro LOG_CC_GRAPH that says whether we should log the graph or not.  If this macro evaluates to true, a CC graph will be logged.

If ALWAYS_LOG_CC_GRAPH is defined, then this is true.  If it isn't defined, then if DEBUG_CC is defined, then it looks up mDrawGraphs in the CC parameters, as usual.  If neither of these is defined, this is false.
This removes the #ifdef DEBUG_CC in a few places, but it turns the branch into an "if (false)" so it should not change a normal optimized build.
Assignee: nobody → continuation
azakai (I think) was asking how to do this a few weeks ago.  This patch makes it easier.
I'll need to update this Wiki page if I change this: https://wiki.mozilla.org/Performance:Leak_Tools
This is less #define magic-y than the other patch. I make mDrawGraphs into a parameter that is always present (and rename it mLogGraphs, as that is more accurate), setting it as appropriate.

To make it always log you only have to change
  #define ALWAYS_LOG_CC_GRAPHS PR_FALSE
to
  #define ALWAYS_LOG_CC_GRAPHS PR_TRUE

This patch also gets rid of two uses of #DEBUG_CC.  I haven't tested it yet.
Attachment #553820 - Attachment is obsolete: true
Mostly the same as the last version, but I use a const global instead of a #define.  I tested this with and without DEBUG_CC, and with DEBUG_CC and XPCOM_CC_DRAW_GRAPHS.  I had to comment out ExplainLiveExpectedGarbage due to Bug 684098, but that shouldn't be a problem.
Attachment #557589 - Attachment is obsolete: true
Attachment #557854 - Flags: review?(bent.mozilla)
Component: XPConnect → XPCOM
QA Contact: xpconnect → xpcom
Comment on attachment 557854 [details] [diff] [review]
add a const to always log the CC graph

Review of attachment 557854 [details] [diff] [review]:
-----------------------------------------------------------------

::: xpcom/base/nsCycleCollector.cpp
@@ +2909,5 @@
>      // disable the collector because the program is shutting down.
>  
> +    nsCOMPtr<nsCycleCollectorLogger> listener;
> +    if (mParams.mLogGraphs)
> +        listener = new nsCycleCollectorLogger();

Nit: Brace this.
Attachment #557854 - Flags: review?(bent.mozilla) → review+
http://hg.mozilla.org/mozilla-central/rev/7946546d5a6c
Status: NEW → RESOLVED
Closed: 9 years ago
Resolution: --- → FIXED
You need to log in before you can comment on or make changes to this bug.