From 06a97c9df06449497e49d0c830e00003af195d2e Mon Sep 17 00:00:00 2001 From: "shanjian%netscape.com" Date: Thu, 17 May 2001 18:24:27 +0000 Subject: [PATCH] #60908 changing character-coding-->auto-detect appears to leak memory r=ftang sr=be Replaced owning com prt with raw ptr (weak ref). --- intl/chardet/src/nsDetectionAdaptor.h | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/intl/chardet/src/nsDetectionAdaptor.h b/intl/chardet/src/nsDetectionAdaptor.h index 58a41cde588d..6f26b70cc3a8 100644 --- a/intl/chardet/src/nsDetectionAdaptor.h +++ b/intl/chardet/src/nsDetectionAdaptor.h @@ -66,8 +66,17 @@ class nsMyObserver : public nsICharsetDetectionObserver private: nsCOMPtr mWebShellSvc; PRBool mNotifyByReload; - nsCOMPtr mWeakRefDocument; - nsCOMPtr mWeakRefParser; + + //The adaptor is owned by parser as filter, and adaptor owns detector, + //which in turn owns observer. Parser also live within the lifespan of + //document. The ownership tree is like: + // document->parser->adaptor->detector->observer + //We do not want to own Document & Parser to avoid ownership loop. That + //will cause memory leakage. + //If in future this chain got changed, ie. parser outlives document, or + //detector outlives parser, we might want to change weak reference here. + nsIDocument* mWeakRefDocument; + nsIParser* mWeakRefParser; nsAutoString mCharset; nsCAutoString mCommand; };