Closed Bug 280808 Opened 20 years ago Closed 20 years ago

XMLHttpRequest leaks

Categories

(Core :: XML, defect)

x86
All
defect
Not set
critical

Tracking

()

RESOLVED FIXED

People

(Reporter: alex, Unassigned)

References

()

Details

(Keywords: memory-leak, regression)

Attachments

(1 file, 1 obsolete file)

XMLHttpRequests leak about 5KB/request in current Mozilla/Firefox trunk builds.
This is a regression from earlier builds. Firefox 1.0 e.g. only leaks requests
if the network is down (a bug in itself).

A testcase is at http://www.croczilla.com/~alex/req/req.html.
The testcase generates aynchronous XMLHttpRequests and lets you adjust the
interval between requests & the page requested.
For current trunk builds on Windows the leak rate at the default interval (50ms)
is about 100KB/s.

FF1.0 will not leak if the network is up and running (even if the requested page
doesn't exist). If you unplug your network connection, however, it also starts
leaking.
A little further investigation shows that it is the nsXMLHttpRequest objects
themselves that are leaking. The leak doesn't seem to have anything to do with
onload, etc. listeners, and it only occurs if send() is called on the request
object.
Attached patch patch for nsHttpChannel.cpp (obsolete) — Splinter Review
Turns out this is a regression caused by bug#261083.
If nsHttpChannel::SetNotificationCallbacks() is called with nsnull, we must
make sure to null-out mHttpEventSink & mProgressSink as well, or otherwise we
end up with a reference cycle nsHttpChannel <--> nsXMLHttpRequest.
Attachment #173214 - Flags: review?(darin)
Hmm... this works, but I think it might be better to release those objects in
nsHttpChannel::OnStopRequest once we know that we will no longer need them.  Can
you give that a try?
Attached patch 2nd trySplinter Review
How about this?
Attachment #173214 - Attachment is obsolete: true
Attachment #173220 - Flags: review?(darin)
Attachment #173214 - Flags: review?(darin)
Comment on attachment 173220 [details] [diff] [review]
2nd try

r=darin
Attachment #173220 - Flags: review?(darin) → review+
Comment on attachment 173220 [details] [diff] [review]
2nd try

sr=bzbarsky
Attachment #173220 - Flags: superreview+
Checked in.
Status: NEW → RESOLVED
Closed: 20 years ago
Resolution: --- → FIXED
Severity: normal → critical
Keywords: mlk
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: