Closed Bug 350949 Opened 18 years ago Closed 18 years ago

Feed preview leaks memory

Categories

(Firefox Graveyard :: RSS Discovery and Preview, defect)

2.0 Branch
PowerPC
macOS
defect
Not set
major

Tracking

(Not tracked)

VERIFIED FIXED
Firefox 2

People

(Reporter: erwan, Assigned: sayrer)

References

()

Details

(Keywords: fixed1.8.1, memory-leak)

Attachments

(3 files, 1 obsolete file)

User-Agent:       Mozilla/5.0 (Macintosh; U; Intel Mac OS X; en-US; rv:1.8.1b2) Gecko/20060821 Firefox/2.0b2
Build Identifier: Mozilla/5.0 (Macintosh; U; Intel Mac OS X; en-US; rv:1.8.1b2) Gecko/20060821 Firefox/2.0b2

Each time a feed is previewed (showing the "Subscribe to this feed using...") a few hundreds of k are leaked.

Reproducible: Always

Steps to Reproduce:
1.Open a memory monitor
2.Open a feed in Firefox
3.Reload constantly the feed (shift+click reload)
4.Watch the memory usage grow up and never be freed

Actual Results:  
Memory usage just grows up

Expected Results:  
Constant memory usage

I think the leak is in the HTMLUnescape function, in mozilla/components/feeds/src:

http://lxr.mozilla.org/mozilla1.8/source/toolkit/components/feeds/src/nsScriptableUnescapeHTML.cpp#82

We were using it to convert HTML to plain text and noticed the leak. The function itself is very short and looks good, so the leak is probably in the HTMLToTextSink.
Severity: normal → major
Status: UNCONFIRMED → NEW
Ever confirmed: true
Keywords: mlk, qawanted
Version: unspecified → 2.0 Branch
Flags: blocking-firefox2?
taking.
Assignee: nobody → sayrer
Flags: blocking-firefox2? → blocking-firefox2+
Target Milestone: --- → Firefox 2
Status: NEW → ASSIGNED
(In reply to comment #0)
> 
> I think the leak is in the HTMLUnescape function, in
> mozilla/components/feeds/src:

I can't reproduce a leak in that function when testing it alone. Could you provide a narrower test case if you can reproduce it?

There is a leak in the FeedResultService, where nsIFeedResults are not removed from the cache if the feed rendering is interupted by a reload. You should see no leak if you wait before pressing reload.
Attached patch Check for multiple list members (obsolete) — Splinter Review
When refresh is hit rapidly, the same URI instance will be added twice.
Attachment #237151 - Flags: review?(bugs.mano)
forgot to delete some logging
Attachment #237151 - Attachment is obsolete: true
Attachment #237152 - Flags: review?(bugs.mano)
Attachment #237151 - Flags: review?(bugs.mano)
(In reply to comment #2)
> I can't reproduce a leak in that function when testing it alone. Could you
> provide a narrower test case if you can reproduce it?

I can still reproduce it. Even if I wait for the page to be rendered, I see the memory use goes up, then down but at the level it was before. (for exemple + 300 kb then - 150 k).

In a different project, I was using the same function to strip html tags and the memory stopped leaking when a switched to simple regexp to strip the tags.

I will try to make a testcase in xpcshell to isolate the leak.

> There is a leak in the FeedResultService, where nsIFeedResults are not removed
> from the cache if the feed rendering is interupted by a reload. You should see
> no leak if you wait before pressing reload.

I think this is unrelated to the leak I am talking about.
Comment on attachment 237152 [details] [diff] [review]
Check for multiple list members

r=mano.
Attachment #237152 - Flags: review?(bugs.mano) → review+
Checking in feeds/src/FeedConverter.js;
/cvsroot/mozilla/browser/components/feeds/src/FeedConverter.js,v  <--  FeedConverter.js
new revision: 1.20; previous revision: 1.19
done
Checking in feeds/src/FeedWriter.js;
/cvsroot/mozilla/browser/components/feeds/src/FeedWriter.js,v  <--  FeedWriter.js
new revision: 1.15; previous revision: 1.14
done
Comment on attachment 237152 [details] [diff] [review]
Check for multiple list members

drivers: this is low-risk, needed to prevent a big leak when reload is hit extremely rapidly.
Attachment #237152 - Flags: approval1.8.1?
Comment on attachment 237152 [details] [diff] [review]
Check for multiple list members

a=beltzner on behalf of 181drivers
Attachment #237152 - Flags: approval1.8.1? → approval1.8.1+
Whiteboard: [checkin needed (1.8 branch)]
Checking in FeedWriter.js;
/cvsroot/mozilla/browser/components/feeds/src/FeedWriter.js,v  <--  FeedWriter.js
new revision: 1.2.2.18; previous revision: 1.2.2.17
done
Checking in FeedConverter.js;
/cvsroot/mozilla/browser/components/feeds/src/FeedConverter.js,v  <--  FeedConverter.js
new revision: 1.1.2.20; previous revision: 1.1.2.19
done
Whiteboard: [checkin needed (1.8 branch)]
Keywords: fixed1.8.1
This property is pretty useless. I never should have added it. As a bonus, it creates reference cycles.
Attachment #237809 - Flags: review?(vladimir)
Comment on attachment 237809 [details] [diff] [review]
remove nsIFeedEntry.parent

Sounds good to me
Attachment #237809 - Flags: review?(vladimir) → review+
Comment on attachment 237809 [details] [diff] [review]
remove nsIFeedEntry.parent

drivers low risk, removing unused API.
Attachment #237809 - Flags: approval1.8.1?
this was recently exposed by changing sendResult(). we don't use the sync methods in Fx, but the test harness does. saw the leak there.
Attachment #237815 - Flags: review?(vladimir)
Attachment #237815 - Flags: approval1.8.1?
Keywords: fixed1.8.1
Whiteboard: [has patch][needs approval]
Comment on attachment 237809 [details] [diff] [review]
remove nsIFeedEntry.parent

a=schrep for 181drivers
Attachment #237809 - Flags: approval1.8.1? → approval1.8.1+
Comment on attachment 237815 [details] [diff] [review]
set reader to null for the sync methods

a=schrep for 181drivers
Attachment #237815 - Flags: approval1.8.1? → approval1.8.1+
Whiteboard: [has patch][needs approval] → [checkin needed (1.8 branch)]
checkin branch attachment 237815 [details] [diff] [review] and attachment 237809 [details] [diff] [review]

Checking in public/nsIFeedEntry.idl;
/cvsroot/mozilla/toolkit/components/feeds/public/nsIFeedEntry.idl,v  <--  nsIFeedEntry.idl
new revision: 1.1.2.5; previous revision: 1.1.2.4
done
Checking in src/FeedProcessor.js;
/cvsroot/mozilla/toolkit/components/feeds/src/FeedProcessor.js,v  <--  FeedProcessor.js
new revision: 1.1.2.13; previous revision: 1.1.2.12
done
Whiteboard: [checkin needed (1.8 branch)]
Whiteboard: [has patch][checkin needed (1.8 branch)]
so, I've chased down everything I can find here, but the Flock guys say they have a leak, so I'm not closing it.
Whiteboard: [has patch][checkin needed (1.8 branch)]
resolved fixed. Erwan: file a new bug and CC me if you can get a small test case.
Status: ASSIGNED → RESOLVED
Closed: 18 years ago
Keywords: fixed1.8.1
Resolution: --- → FIXED
Thank you Robert. I'll grab a new build and see if I can reproduce the bug in a small xpcshell script.
On Firefox 3.5, I tested the planet planet.mozilla.org feed and reloaded it repeatedly.  After a few seconds garbage collection (or something similar) occurred and memory went back to normal, and when the tab was closed it returned to the memory level from before the feed was opened.

Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.1.2)

Verifying as fixed; removing qawanted.

Is there anything else that needs to be verified or checked?
Status: RESOLVED → VERIFIED
Keywords: qawanted
Product: Firefox → Firefox Graveyard
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: