diff --git a/mozilla/xpcom/threads/nsEventQueue.cpp b/mozilla/xpcom/threads/nsEventQueue.cpp index 86ba9e5049d..1965f3fee6b 100644 --- a/mozilla/xpcom/threads/nsEventQueue.cpp +++ b/mozilla/xpcom/threads/nsEventQueue.cpp @@ -47,6 +47,10 @@ #include "prlog.h" +#ifdef NS_DEBUG +#include "prprf.h" +#endif + #if defined(PR_LOGGING) && defined(DEBUG_danm) /* found these logs useful in conjunction with netlibStreamEvent logging from netwerk. */ @@ -509,6 +513,21 @@ nsEventQueueImpl::AppendQueue(nsIEventQueue *aQueue) */ rv = NS_ERROR_NO_INTERFACE; +#ifdef NS_DEBUG + int depth = 0; + nsEventQueueImpl *next = this; + while (next && depth < 100) { + next = NS_STATIC_CAST(nsEventQueueImpl *, next->mYoungerQueue); + ++depth; + } + if (depth > 5) { + char warning[80]; + PR_snprintf(warning, sizeof(warning), + "event queue chain length is %d. this is almost certainly a leak.", depth); + NS_WARNING(warning); + } +#endif + // (be careful doing this outside nsEventQueueService's mEventQMonitor) GetYoungest(getter_AddRefs(end));