Closed Bug 60908 Opened 25 years ago Closed 25 years ago

changing character-coding-->auto-detect appears to leak memory

Categories

(Core :: Internationalization, defect, P1)

x86
Linux
defect

Tracking

()

VERIFIED FIXED
mozilla0.9.1

People

(Reporter: matt, Assigned: shanjian)

References

()

Details

(Keywords: intl, memory-leak, Whiteboard: ready to check in.)

Attachments

(2 files)

1. Load URL specified 2. View-->Character Coding-->Auto-detect-->Off 3. View-->Character Coding-->Auto-detect-->Japanese (note resident memory usage using "ps v") 4. repeat steps 2 and 3 result: There appears to be in incremental memory leak every time Character Coding is changed
over to I18N
Assignee: asa → nhotta
Status: UNCONFIRMED → NEW
Component: Browser-General → Internationalization
Ever confirmed: true
QA Contact: doronr → teruko
Shanjian, could you take a look at this?
Assignee: nhotta → shanjian
Keywords: intl
leak issue. mark it as P1.
Priority: P3 → P1
Changed QA contact to andreasb@netscape.com for now.
QA Contact: teruko → andreasb
qa=ylong
QA Contact: andreasb → ylong
accept it.
Status: NEW → ASSIGNED
reassign to roy
Assignee: shanjian → yokoyama
Status: ASSIGNED → NEW
Status: NEW → ASSIGNED
Target Milestone: --- → mozilla0.9.1
matt: i am running Purify on Window using 20010424 build; but it doesn't complain about incremental memory leak. Purify is pretty good at finding leaks. Can you verify if the bug still exists? If still exists, what kind of tool do you use to reproduce this bug? I can ask bstell to help me out for Linux problem.
Adding nsbeta1 keyword.
Keywords: nsbeta1
Are you using Purify 2000 or 2001? I generally find Insure++ to be more accuruate when it comes to reporting leaks, Purify is better for API checking (invalid parameters, handles, etc). I wa on Linux, and using 'ps vxf' to show the RSS size of the mozilla process. the RSS size increased incrementally each time I did the steps below. I mostly am using Solaris now, but I can try reproducing on Linux if you like. Mozilla's Solaris builds have been much less stable/functional than the Linux builds so far.
It seems that we're leaking some content nodes every time we reload the page (whether it's by an auto-detect change or a simple reload). I recommend looking at this with the XPCOM leak tools since they may not be leaks to something that uses GC-based leak detection (since they may still be reachable through the JS GC heap or something).
matt: I'd really appreciate if you could try this bug in Linux (may be using Insure++). I'd like to identify if the leak is happening on a simple reload. Since the auto-detect menu selection forces to page reload, this bug may be non-i18n related.
I traced at least some of the leaks to a cycle between the nsHTMLImageElement (an nsGenericElement) and its imgRequestProxy. But I couldn't get the NSPR log of the imgRequestProxy data and the refcount logs to have the same |this| in them...
Blocks: 75641
Matt: would you try this same test but just do a 'force' reload instead of a character set change? If most of the leak still occurs without changing the character set then we should probably reassign to non-i18n.
David Baron: Is this anything to do with Auto-detect or simply leaks on reload? If leaks on reload, then (as Brian suggests) we should assign this bug to non-i18n.
I can't confirm this on Windows + Purify. Assign back to Shanjian.
Assignee: yokoyama → shanjian
Status: ASSIGNED → NEW
In file "mozilla/intl/chardet/src/nsDetectionAdaptor.h", mWeakRefParser is declared as COMPtr, that is an owning pointer. As a consequence, mOberser owns this mWeakRefParser, and nsDetectionAdaptor owns mObserser, nsParser owns nsDetectionAdaptor. That's a LOOP! After I replaced COMPtr with interface pointer, those instances do get destroyed. However, the destructor of nsDetectionAdaptor cause window debug warning message, which say the memory block is damaged. I haven't been able to find out what is the problem yet.
Attached patch proposed patch. — — Splinter Review
Frank, can you review my fix? Brendan, could you do sr? This should be a purely XPCOM pointer issue. Thanks!
Status: NEW → ASSIGNED
What keeps those pointers from dangling if the document or parser goes away? /be
These two pointer used to be raw pointer in nsDetectionAdaptor.cpp When yokoyama move it from nsDetectionAdaptor.cpp to nsDetectionAdaptor.h in Apr 11 19:05 see (r.1.14 of nsDetectionAdaptor.cpp) , he change it to nsCOMPtr<> We have to keep it as non nsCOMPtr since they are >What keeps those pointers from dangling if the document or parser goes away? nsIParser ref to nsDetectionAdaptor (see content/html/document/src/nsHTMLDocument.cpp ) 576 nsCOMPtr <nsIParserFilter> cdetflt; .... 797 cdetflt = do_CreateInstance(NS_CHARSET_DETECTION_ADAPTOR_CONTRACTID, 798 &rv_detect); ... 862 if(cdetflt) 863 // The current implementation for SetParserFilter needs to 864 // be changed to be more XPCOM friendly. See bug #40149 865 nsCOMPtr<nsIParserFilter> oldFilter = getter_AddRefs(mParser->SetParserFilter(cdetflt)); therefore we can guarantee that mWeakRefParser is always there. also, Parser are owned by nsHTMLDocument itself, therefore, we can gurantee taht the mWeakRefDocument is also there.
"also, Parser are owned by nsHTMLDocument itself, therefore, we can gurantee that the mWeakRefDocument is also there." Thanks -- this is all worth saying in a comment in the .h file. If someone later changes things so that the parser can outlive the document, or some such, that may help track down the crash. Roy, sr=brendan@mozilla.org if you add a nice comment explaining the tree-like ownership chain from document to parser to detector-adaptor. /be
comment added as suggested.
(Sorry Shanjian, I thought Roy had this bug! Anyway, sr= still stands unless you would like me to review the comment too.)
Memory leak. This one needs to be fixed.
Whiteboard: ready to check in.
One question: This bug is about incremental memory leak in Auto-detect and filed 2000-11-21 which is nothing to do with my April check-in. Is the incremental memory leak fixed as well?
I have no idea when this began to happen or either we have other leakage related with auto detection or not. I did checked all major objects allocated this auto detect, and all of them are released after this patch.
fix checked in.
Status: ASSIGNED → RESOLVED
Closed: 25 years ago
Resolution: --- → FIXED
The original 2000-11-21 leak was not diagnosed, so all we can do is make sure that there are no leaks currently that can be attributed to this UI. /be
Shanjian, how can I verify this?
Verified.
Status: RESOLVED → VERIFIED
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: