Issue 52411 in chromium: AJAX Memory Leak - Chrome Never Releases Memory Consumed by AJAX Unless Tab is Closed

340 views
Skip to first unread message

chro...@googlecode.com

unread,
Aug 17, 2010, 8:46:04 AM8/17/10
to chromi...@chromium.org
Status: Unconfirmed
Owner: ----
Labels: Type-Bug Pri-2 Area-Undefined

New issue 52411 by Tony.Val...@PowerDNN.com: AJAX Memory Leak - Chrome
Never Releases Memory Consumed by AJAX Unless Tab is Closed
http://code.google.com/p/chromium/issues/detail?id=52411

Chrome Version : 5.0.375.126
URLs (if applicable) : Any URL using Ajax.
http://www.asp.net/ajax/ajaxcontroltoolkit/Samples/DynamicPopulate/DynamicPopulate.aspx
Other browsers tested:
Add OK or FAIL after other browsers where you have tested this issue:
Firefox 3.x: OK
IE 7: OK
IE 8: OK

What steps will reproduce the problem?
1. Go to a website that has AJAX stuff on it such as:
http://www.asp.net/ajax/ajaxcontroltoolkit/Samples/DynamicPopulate/DynamicPopulate.aspx

2. Cause the AJAX code to execute over and over again.

3. You'll see that tab's memory usage go higher and higher and then Chrome
will error out at you. Chrome never releases the memory.


What is the expected result?
Chrome should release memory associated with old AJAX requests.

What happens instead?
Chrome just keeps using more and more memory.

Please provide any additional information below. Attach a screenshot if
possible.
In the screen shot, I'm using a program named Kayako Fusion V4.0 (it is the
latest release of a highly popular Helpdesk program). Kayako Fusion V4.0
is completely AJAX based which is what brought this to my attention. At
first, I thought it may be an issue with Kayako since it is beta software,
however, I tested with IE and FF and I did not get the large memory usage
that I do with Chrome. I then went to other websites that use AJAX and
verified that after repeated actions, Chrome's memory goes higher and
higher and it never appears to release any memory.


Attachments:
Google Chrome.jpg 170 KB

chro...@googlecode.com

unread,
Oct 17, 2010, 7:34:12 AM10/17/10
to chromi...@chromium.org
Updates:
Status: Untriaged
Labels: -Area-Undefined Area-Internals Memory WebKit-JavaScript
Area-WebKit Internals-Core

Comment #1 on issue 52411 by phist...@chromium.org: AJAX Memory Leak -

Chrome Never Releases Memory Consumed by AJAX Unless Tab is Closed
http://code.google.com/p/chromium/issues/detail?id=52411

Perhaps not the best reduced test case, but here it is -
function read()
{
var xhr = new XMLHttpRequest();
xhr.onreadystatechange = function()
{
if (xhr.readyState == 4)
{
setTimeout(read, 5000);
xhr = null;
delete xhr;};
}
xhr.open("GET", '/', true);
xhr.send();

}

read();

Confirmed on Windows Vista Home Premium SP 2 and Chrome 8.0.552.X dev and
on Windows XP Professional SP 2 and Chrome 8.0.555.0 canary build (both of
them uses the Classic Windows theme).

chro...@googlecode.com

unread,
Oct 19, 2010, 11:04:09 AM10/19/10
to chromi...@chromium.org

Comment #2 on issue 52411 by dunn.matt.w: AJAX Memory Leak - Chrome Never
Releases Memory Consumed by AJAX Unless Tab is Closed
http://code.google.com/p/chromium/issues/detail?id=52411

A real world test could be ComicBookRealm.com. I have noticed that after
using the site for a while with Chrome my computer gets really slow. I
then notice that Chrome is using a lot of memory. This site is primarily
AJAX driven (looks like jQuery). If I switch to FF or even IE I do not
experience the problem.

chro...@googlecode.com

unread,
Nov 11, 2010, 6:23:55 AM11/11/10
to chromi...@chromium.org
Updates:
Status: Started
Owner: ant...@chromium.org

Comment #5 on issue 52411 by ant...@chromium.org: AJAX Memory Leak - Chrome

Never Releases Memory Consumed by AJAX Unless Tab is Closed
http://code.google.com/p/chromium/issues/detail?id=52411

I'll have a look.

chro...@googlecode.com

unread,
Nov 12, 2010, 11:42:21 AM11/12/10
to chromi...@chromium.org
Updates:
Status: Unconfirmed

Comment #7 on issue 52411 by ant...@chromium.org: AJAX Memory Leak - Chrome

Never Releases Memory Consumed by AJAX Unless Tab is Closed
http://code.google.com/p/chromium/issues/detail?id=52411

Sorry, guys, I need more info.

First of all, please, if you have any extensions installed, it'd be great
if you could share the list with me.

http://www.asp.net/ajax/ajaxcontroltoolkit/Samples/DynamicPopulate/DynamicPopulate.aspx
looks
fine to me: Tony.V...@PowerDNN.com, may you double check if you
experience any problem with the recent Chrome? a.rzadkowolski currently
sees none.

phis...@chromium.org: what kind of leak are you observing? Memory usage
can grow really high as only tiny JS objects are created, but we should
forcefully trigger GC when total memory usage will grow too high. Another
way to check if there is a real leak is to make a couple of heap snapshots
with Developer tools: heap snapshots both perform GC and could point out
what exactly is leaking.

Or just leave the tab in background and check it memory usage later.

If you still see a leak which breaks 512M limit on Windows, may I ask you
to give me a self-contained HTML?

And FYI, once there was a suspicion we have XHR leak pretty much like you
describe, but it turned to be false alarm.

dunn.matt.w: very important thing is to learn if you have any extensions
installed: some of them trigger leak like behaviour, esp. for site which
create many frames. Bug again, in my extension less Chrome I see no leaks.

Thanks a lot for reporting problematic case and sorry that I am bothering
you with additional stuff.

chro...@googlecode.com

unread,
Nov 12, 2010, 11:54:51 AM11/12/10
to chromi...@chromium.org

Comment #8 on issue 52411 by phistuck: AJAX Memory Leak - Chrome Never
Releases Memory Consumed by AJAX Unless Tab is Closed
http://code.google.com/p/chromium/issues/detail?id=52411

@antonm - the memory just grows. If I explicitly delete that object (notice
the "delete xhr;"), why does the memory keep on growing?

chro...@googlecode.com

unread,
Nov 12, 2010, 11:58:53 AM11/12/10
to chromi...@chromium.org

Comment #9 on issue 52411 by Tony.Val...@PowerDNN.com: AJAX Memory Leak -
Chrome Never Releases Memory Consumed by AJAX Unless Tab is Closed
http://code.google.com/p/chromium/issues/detail?id=52411

Hi all,
I just tested this again in Chrome 9.0 on the dev channel, and this is
still an issue. I do not have any extensions installed. I don't know how
to forcefully cause GC to happen, but I can tell you that it should have
happened automatically well before using 800MB of RAM.

-Tony V.

chro...@googlecode.com

unread,
Nov 12, 2010, 12:15:04 PM11/12/10
to chromi...@chromium.org

Comment #10 on issue 52411 by ant...@chromium.org: AJAX Memory Leak -
Chrome Never Releases Memory Consumed by AJAX Unless Tab is Closed
http://code.google.com/p/chromium/issues/detail?id=52411

yep, I saw delete, but delete is only a hind and does nothing in v8, v8
releases memory only when performs GC.

There are several events which could trigger GC. In the most cases v8
triggers GC when a lot of memory for JS objects has been allocated.

There is a well-known problem with tiny v8 objects holding huge native
objects: think XHR requests where v8 create pretty small objects, roughly 4
words and keeps a pointer to WebKit string which might be pretty big or JS
wrappers for DOM objects.

To solve it v8 and WebKit has additional protocol like reporting amount of
external memory held by v8 strings or forcing GC when memory usage is
getting too high.

Resume: JS delete doesn't guarantee memory release and events which trigger
GC and hence memory release might be quite surprising.

chro...@googlecode.com

unread,
Nov 12, 2010, 12:23:19 PM11/12/10
to chromi...@chromium.org

Comment #11 on issue 52411 by ant...@chromium.org: AJAX Memory Leak -
Chrome Never Releases Memory Consumed by AJAX Unless Tab is Closed
http://code.google.com/p/chromium/issues/detail?id=52411

Tony,

what exactly you're doing? 800M is definitely too much. But on my Chrome
(MacOS, 7.0.517.44) opening a site for a minute doesn't reveal any notable
memory usage growth.

Do you just keep site longer? Which sections do you navigate? What are
you doing?

Thanks a lot for keep an eye on this issue.

chro...@googlecode.com

unread,
Nov 14, 2010, 5:42:04 AM11/14/10
to chromi...@chromium.org

Comment #12 on issue 52411 by a.rzadko...@gmail.com: AJAX Memory Leak -
Chrome Never Releases Memory Consumed by AJAX Unless Tab is Closed
http://code.google.com/p/chromium/issues/detail?id=52411

Hey again @antonm,

I am developing extension
https://chrome.google.com/extensions/detail/effhaohnpfmphdbipcijflpkkgpakcma
and it makes requests to www.facebook.com/reqs.php
in versions of chrome prior 9.0 the memory was just growing.

The file it's downloading is 500KB so it's a bit of data.

Please try requesting this address with phistuck code, it should give you
some clarification.


function read()
{
var xhr = new XMLHttpRequest();
xhr.onreadystatechange = function()
{
if (xhr.readyState == 4)
{
setTimeout(read, 5000);
xhr = null;
delete xhr;};
}

xhr.open("GET", 'http://www.facebook.com/reqs.php', true);
xhr.send();

}

chro...@googlecode.com

unread,
Nov 14, 2010, 6:43:19 AM11/14/10
to chromi...@chromium.org

Comment #13 on issue 52411 by Tony.Val...@PowerDNN.com: AJAX Memory Leak -
Chrome Never Releases Memory Consumed by AJAX Unless Tab is Closed
http://code.google.com/p/chromium/issues/detail?id=52411

In my case, there is an AJAX-based application that we use. Instead of
loading a new page, _EVERY_ request after the first one is retrieved via
ajax.

After using the app for a while, chrome consumes all that RAM.

chro...@googlecode.com

unread,
Nov 15, 2010, 7:38:15 AM11/15/10
to chromi...@chromium.org

Comment #14 on issue 52411 by ant...@chromium.org: AJAX Memory Leak -
Chrome Never Releases Memory Consumed by AJAX Unless Tab is Closed
http://code.google.com/p/chromium/issues/detail?id=52411

@a.rzadkowolski: thanks, I experimented with things like that and observed
no memory leak (but at least for http://www.facebook.com/reqs.php I've got
zero length responseText

@Tony: Tony, to see what goes wrong I need a repro case.

chro...@googlecode.com

unread,
Nov 16, 2010, 6:17:26 AM11/16/10
to chromi...@chromium.org

Comment #16 on issue 52411 by a.rzadko...@gmail.com: AJAX Memory Leak -
Chrome Never Releases Memory Consumed by AJAX Unless Tab is Closed
http://code.google.com/p/chromium/issues/detail?id=52411

@antonm if you get zero length you can't repro it :) You can try then:
http://www.facebook.com/?sk=games (it's almost the same size) with version
6 and 7 it grew up really fast to even 800MB (when using 10-15 seconds
timeout)

chro...@googlecode.com

unread,
Nov 22, 2010, 6:21:29 AM11/22/10
to chromi...@chromium.org

Comment #17 on issue 52411 by ant...@chromium.org: AJAX Memory Leak -
Chrome Never Releases Memory Consumed by AJAX Unless Tab is Closed
http://code.google.com/p/chromium/issues/detail?id=52411

@a.rzadkowolski: please, find the attached file. It still reports
xhr.reponseText.length is 0. May you turn it into the repro? Thank you in
advance.

Attachments:
test.html 351 bytes

chro...@googlecode.com

unread,
Nov 22, 2010, 6:53:43 AM11/22/10
to chromi...@chromium.org

Comment #18 on issue 52411 by phistuck: AJAX Memory Leak - Chrome Never
Releases Memory Consumed by AJAX Unless Tab is Closed
http://code.google.com/p/chromium/issues/detail?id=52411

@antonm - try that inside the background page of the extension. Remember,
you cannot make cross origin requests with regular web pages, so you always
get no response through the API.

chro...@googlecode.com

unread,
Nov 22, 2010, 6:57:45 AM11/22/10
to chromi...@chromium.org

Comment #19 on issue 52411 by phistuck: AJAX Memory Leak - Chrome Never
Releases Memory Consumed by AJAX Unless Tab is Closed
http://code.google.com/p/chromium/issues/detail?id=52411

@antonm - Of course, add a permission for http://www.facebook.com.

chro...@googlecode.com

unread,
Nov 22, 2010, 7:17:59 AM11/22/10
to chromi...@chromium.org

Comment #20 on issue 52411 by ant...@chromium.org: AJAX Memory Leak -
Chrome Never Releases Memory Consumed by AJAX Unless Tab is Closed
http://code.google.com/p/chromium/issues/detail?id=52411

@phistuck: do you suspect it's extensions related? if not, I'd rather have
a simple single page repro for it.

chro...@googlecode.com

unread,
Nov 22, 2010, 8:02:51 AM11/22/10
to chromi...@chromium.org

Comment #21 on issue 52411 by phistuck: AJAX Memory Leak - Chrome Never
Releases Memory Consumed by AJAX Unless Tab is Closed
http://code.google.com/p/chromium/issues/detail?id=52411

@antonm - No, I was just pointing out a way to get this actually working.
A simple page would not work on the file:// scheme, because of the security
policy Chrome maintains (no access to files from files or from anything
else).
You can run the script through the Developer Tools console when you are
within a Facebook page (so it would not be a cross origin request).

Or start Chrome with --disable-web-security.

chro...@googlecode.com

unread,
Dec 1, 2010, 9:03:27 AM12/1/10
to chromi...@chromium.org

Comment #24 on issue 52411 by a.rzadko...@gmail.com: AJAX Memory Leak -
Chrome Never Releases Memory Consumed by AJAX Unless Tab is Closed
http://code.google.com/p/chromium/issues/detail?id=52411

I have included simple extension that experience this problem. (you must be
logged to facebook before using it)

Also an image: attached script was run for 15 minutes on both: Chrome 6
(lower row: 140MB) and Chrome 9 (upper row: 14MB). As you can see it was
fixed in chrome 9.

Attachments:
leak.zip 24.8 KB
mem_usage.png 4.7 KB

chro...@googlecode.com

unread,
Dec 1, 2010, 9:32:34 AM12/1/10
to chromi...@chromium.org

Comment #25 on issue 52411 by a.rzadko...@gmail.com: AJAX Memory Leak -
Chrome Never Releases Memory Consumed by AJAX Unless Tab is Closed
http://code.google.com/p/chromium/issues/detail?id=52411

One more photo after more 39 minutes.

Attachments:
mem_usage2.png 53.2 KB

chro...@googlecode.com

unread,
May 16, 2011, 9:02:54 AM5/16/11
to chromi...@chromium.org

Comment #28 on issue 52411 by timu...@chromium.org: AJAX Memory Leak -
Chrome Never Releases Memory Consumed by AJAX Unless Tab is Closed
http://code.google.com/p/chromium/issues/detail?id=52411

Anton, can you please re-visit?

Someone complains about very-similar leaks in Chrome 10 (April 2011)
http://habrahabr.ru/blogs/javascript/117909/

chro...@googlecode.com

unread,
May 18, 2011, 4:29:48 PM5/18/11
to chromi...@chromium.org

Comment #29 on issue 52411 by ant...@chromium.org: AJAX Memory Leak -
Chrome Never Releases Memory Consumed by AJAX Unless Tab is Closed
http://code.google.com/p/chromium/issues/detail?id=52411

I did. And still I am not convinced it's a leak.

What I did: just add 5 forced gc (exposing it with --expose-gc flag) in
callbacks. Then ran it for ~10hrs. Results are no memory growth. There
is some fragmentation piling up, but that's due to the fact that GC picks
mark-sweep which doesn't do compaction.

Overall, notion of leak in GCed language is rather involved. And both V8
and V8 DOM bindings have a lot of various instruments to keep memory usage
under control while maintaining necessary performance.

The classic leak would be something which quickly exhausts the heap and
make Chrome crash with out of memory. Just memory growth, esp. flat or
until it reaches big numbers, might signify that v8 decided not to spend
too much time collecting all the garbage.

Leaving wonfit for now. But if I miss any points, please, let me know.

chro...@googlecode.com

unread,
Apr 9, 2012, 9:27:38 PM4/9/12
to chromi...@chromium.org

Comment #30 on issue 52411 by p...@isomorphic.com: AJAX Memory Leak -
Chrome Never Releases Memory Consumed by AJAX Unless Tab is Closed
http://code.google.com/p/chromium/issues/detail?id=52411

It appears that this is still an issue, at least on Windows 7.

Here's a fully standalone runnable test case that rapidly consumes all
available system memory and then crashes Chrome (18.0.1025.151 m) running
on Windows 7.

All this does is issues a new XMLHttpRequest for a JSON style response (a
static text file in this case, Response.txt) with a changing parameter on
the URL.

To run the test, just drop both the html file and the txt file into the
same dir of your server (I'm testing against Tomcat) and hit the HTML file
with Chrome.

Watching the windows Resource Monitor, one of the Chrome.exe processes will
rapidly consume all available memory until the browser crashes.

Regards
Paul Notley

Attachments:
XMLHttpRequest_leak.html 2.3 KB
Response.txt 174 KB

chro...@googlecode.com

unread,
Apr 11, 2012, 8:57:32 AM4/11/12
to chromi...@chromium.org
Updates:
Status: Assigned
Owner: ul...@chromium.org

Comment #31 on issue 52411 by da...@chromium.org: AJAX Memory Leak - Chrome

Never Releases Memory Consumed by AJAX Unless Tab is Closed
http://code.google.com/p/chromium/issues/detail?id=52411

(No comment was entered for this change.)

chro...@googlecode.com

unread,
Apr 11, 2012, 8:59:12 AM4/11/12
to chromi...@chromium.org

Comment #32 on issue 52411 by da...@chromium.org: AJAX Memory Leak - Chrome
Never Releases Memory Consumed by AJAX Unless Tab is Closed
http://code.google.com/p/chromium/issues/detail?id=52411

Ulan, can you please take a look if the new script indeed does cause a
crash in V8? It might be a new, different problem. Anton said he can give
you assistance and background about this bug.

chro...@googlecode.com

unread,
Apr 30, 2012, 6:05:14 AM4/30/12
to chromi...@chromium.org
Updates:
Cc: joc...@chromium.org

Comment #33 on issue 52411 by ul...@chromium.org: AJAX Memory Leak - Chrome
Never Releases Memory Consumed by AJAX Unless Tab is Closed
http://code.google.com/p/chromium/issues/detail?id=52411

The memory leak reproduces in Linux with Chrome ToT. It looks like an old
issue, because I could reproduce the leak in Chrome 16 too. I used nginx as
a web server.

I attached a heap profile after running for 38 hours. V8 heap is small
(32Mb new space + 20Mb old space) compared to WebKit heap (~800Mb).

@Anton, Jochen:

Do the stack traces in the heap profile look familiar? Are there known
issues with WebCore::XMLHttpRequest::callReadyStateChangeListener,
WebCore::V8XMLHttpRequest::sendCallback,
WebCore::CachedResourceLoader::requestResource ?


Attachments:
heap-profile.html 28.4 KB

chro...@googlecode.com

unread,
Apr 30, 2012, 11:30:59 AM4/30/12
to chromi...@chromium.org

Comment #34 on issue 52411 by tony.val...@powerdnn.com: AJAX Memory Leak -
Chrome Never Releases Memory Consumed by AJAX Unless Tab is Closed
http://code.google.com/p/chromium/issues/detail?id=52411

@Ulan - Thanks for working on this. We use chrome almost exclusively at
our organization, but we've had to resort to IE for some of our web apps
because of this bug. I hope ya'll are able to get this fixed sooner than
later.

chro...@googlecode.com

unread,
May 7, 2012, 10:17:07 AM5/7/12
to chromi...@chromium.org
Updates:
Owner: jap...@chromium.org
Cc: ul...@chromium.org

Comment #35 on issue 52411 by ul...@chromium.org: AJAX Memory Leak - Chrome
Never Releases Memory Consumed by AJAX Unless Tab is Closed
http://code.google.com/p/chromium/issues/detail?id=52411

After changing POST request to GET request in the reproduction test, I am
getting a very bad memory leak: memory usage goes to 1GB in a few seconds.

So there are two memory leaks:
- a slow leak that seems to be old (see comment 33).
- a fast leak that starts in Chrome 17 @ r107326.

I bisected the fast leak to WebKit revision 98380 [Make
DocumentThreadableLoader a CachedResourceClient.]
http://trac.webkit.org/changeset/98380/

Nate, could you please look into this?

Steps to reproduce with the nginx webserver:
- install nginx from http://wiki.nginx.org (this might require installing
libpcre3 libpcre3-dev).
- copy the attached ajax.html and Response.txt files to nginx-root/html
directory,
- copy the attached nginx.conf file to nginx-root/conf directory,
- make sure that "http://localhost:8080/Response.txt?i=20" doesn't return
an error,
- open "http://localhost:8080/ajax.html" in browser, click "OK",
- wait about 20-30 seconds,
- renderer process memory usage > 1GB.

Attachments:
ajax.html 2.7 KB
Response.txt 174 KB
nginx.conf 2.7 KB

chro...@googlecode.com

unread,
May 11, 2012, 11:11:31 AM5/11/12
to chromi...@chromium.org

Comment #37 on issue 52411 by ul...@chromium.org: AJAX Memory Leak - Chrome
Never Releases Memory Consumed by AJAX Unless Tab is Closed
http://code.google.com/p/chromium/issues/detail?id=52411

You're right. The fast leak does not occur on dev and beta. I saw it on
stable and bisected further down. I somehow assumed that since the slow
leak occurs on ToT, the fast leak should be there too. My bad, sorry about
it.

Now I bisected up from stable and found out that
http://trac.webkit.org/changeset/107672 fixed the fast leak.

I think Paul Notley was referring to the fast leak (see comment 30). So
this sub-issue is fixed in Chrome 19/20.

Please feel free to reassign the slow leak issue to someone who worked with
WebCore::XMLHttpRequest::callReadyStateChangeListener,
WebCore::V8XMLHttpRequest::sendCallback,
WebCore::CachedResourceLoader::requestResource (see comment 33).


chro...@googlecode.com

unread,
Aug 12, 2012, 4:04:28 PM8/12/12
to chromi...@chromium.org

Comment #38 on issue 52411 by j...@greenhousepc.com: AJAX Memory Leak -
Chrome Never Releases Memory Consumed by AJAX Unless Tab is Closed
http://code.google.com/p/chromium/issues/detail?id=52411

I'm still seeing a fairly nasty memory leak on Chrome version 21 ("up to
date").

I'm using jQuery and jqPlot to render pages. Memory utilization steadily
climbs on the page until it results in a Windows "low on memory" error.

I've had to change the page so it stops automatically updating after an
hour, to avoid this problem. You can view the page at

http://dev.greenhousepc.com:8080/inverter.html?port=1

Nota bene -- As much as I prefer Chrome and Chromium, I'm going to have to
mark them "Unsuppported" for all of my company's products if these leaks
aren't fixed. I've been tracking various memory leak bugs and they seem to
be legion.

chro...@googlecode.com

unread,
Sep 27, 2012, 5:43:37 AM9/27/12
to chromi...@chromium.org

Comment #39 on issue 52411 by krakover...@gmail.com: AJAX Memory Leak -
Chrome Never Releases Memory Consumed by AJAX Unless Tab is Closed
http://code.google.com/p/chromium/issues/detail?id=52411

After reading about the "Slow leak" that release itself only once the tab
had been closed.
On an extension, Since the BG page lives even after the tab had been
closed, Can it be that the process will just go bigger until all Chrome
process will been closed?


chro...@googlecode.com

unread,
Oct 1, 2012, 7:47:06 AM10/1/12
to chromi...@chromium.org

Comment #40 on issue 52411 by armin.pf...@gmail.com: AJAX Memory Leak -
Chrome Never Releases Memory Consumed by AJAX Unless Tab is Closed
http://code.google.com/p/chromium/issues/detail?id=52411

Hi there,

I can also confirm that I currently experience a memory leak when sending
XMLHttpRequests on a regular basis. I am developing a webapp which is going
to "run forever" with a data refresh every second via AJAX (no cross
domain!), so no page refresh and no browser or tab restart is an option.
First of all, I thought my Javascript-Framework (Dojo) was causing this
behaviour. And indeed, by switching to native implementation with the
XMLHttpRequest object I could reduce the memory growth dramatically, but it
still exists on my Chrome 22.0.1229.79 m in Windows 7 and also I
experienced the same issue on Chrome 22.0.1229.79 on my macbook pro with
Mountain Lion. With each ajax request the memory usage is growing a little
bit (about 4-8KB).

So starting at 7500KB memory usage (information from built-in taskmanager)
when opening the attached test html (memory-leak.html) and let it run until
the next morning, the memory usage rose up to over 20000KB. I have tested
all suggested bug fixes (like deleting the xhr object after each iteration,
reuse the xhr object, setting it to null, aborting the old request,
resetting the onreadystatechange handler etc.) as mentioned above, but
nothing really helps. Is there a possibility to fix this with Javascript or
is this a bug related to chrome/webbrowsers (whereas i observed the same
issue in firefox, just as an info...)?

Any help would be appreciated, thanks in advance!

Attachments:
memory-leak.html 830 bytes
memory-leak.json 217 bytes

chro...@googlecode.com

unread,
Oct 1, 2012, 12:16:32 PM10/1/12
to chromi...@chromium.org

Comment #41 on issue 52411 by tony.val...@perigonnetworks.com: AJAX Memory
Leak - Chrome Never Releases Memory Consumed by AJAX Unless Tab is Closed
http://code.google.com/p/chromium/issues/detail?id=52411

I am eligible for $1337? Reporting a memory leak that takes over 2 years
to fix should be worth something!

chro...@googlecode.com

unread,
Oct 4, 2012, 5:19:15 PM10/4/12
to chromi...@chromium.org

Comment #42 on issue 52411 by jap...@chromium.org: AJAX Memory Leak -
Chrome Never Releases Memory Consumed by AJAX Unless Tab is Closed
http://code.google.com/p/chromium/issues/detail?id=52411

Comment #40: I've been playing around with your test. 7.5MB->20MB overnight
is more or less expected, as our in-memory cache is generally large than
that. Most of the JS objects will be reclaimed by the garbage collector,
but we'll retain the raw XHR data in case it gets requested again.
Eventually we'll hit the cache's memory limit, evict that data, and reclaim
the memory.

I tried increasing the size of the json file to speed up filling the cache
and don't see anything obvious in the heap, but I'll leave it running
overnight and see what happens.

chro...@googlecode.com

unread,
Oct 5, 2012, 3:43:30 AM10/5/12
to chromi...@chromium.org

Comment #43 on issue 52411 by armin.pf...@gmail.com: AJAX Memory Leak -
Chrome Never Releases Memory Consumed by AJAX Unless Tab is Closed
http://code.google.com/p/chromium/issues/detail?id=52411

So this means - if I understood you correctly - that I have no control,
whether Chrome stores this raw XHR data or not via Javascript, because it's
a built-in mechanism. But as soon as the internal limit is reached, you
will evict the data ... and you are sure that there's not the possibility
that this could lead to a browser crash if the application runs for 1 week,
1 month or even 1 year? Or would you recommend another mechanism to realize
such an approach?

Thank you for looking into this topic, your help is greatly appreciated!

chro...@googlecode.com

unread,
Oct 5, 2012, 2:42:28 PM10/5/12
to chromi...@chromium.org

Comment #44 on issue 52411 by jap...@chromium.org: AJAX Memory Leak -
Chrome Never Releases Memory Consumed by AJAX Unless Tab is Closed
http://code.google.com/p/chromium/issues/detail?id=52411

I'm sure that if the memory growth is caused by caching instead of a
genuine leak, you shouldn't crash because of memory exhaustion. I'm not
100% sure that there isn't a genuine leak, but I'm still looking :)

Unfortunately, my machine freaked out overnight and I lost my experiment,
so I'll have to try again.

chro...@googlecode.com

unread,
Oct 19, 2012, 9:15:35 PM10/19/12
to chromi...@chromium.org

Comment #45 on issue 52411 by jap...@chromium.org: AJAX Memory Leak -
Chrome Never Releases Memory Consumed by AJAX Unless Tab is Closed
http://code.google.com/p/chromium/issues/detail?id=52411

I left my test case running for roughly a week, during which time it leaked
several hundred megabytes. It appears a large part of the leaks were url
strings that weren't getting reclaimed.

I don't know much about WTF::String and its lifetime characteristics, so
I'll either need to find a new owner or start learning.

chro...@googlecode.com

unread,
Oct 19, 2012, 10:55:39 PM10/19/12
to chromi...@chromium.org
Updates:
Cc: dcar...@chromium.org

Comment #46 on issue 52411 by joc...@chromium.org: AJAX Memory Leak -
Chrome Never Releases Memory Consumed by AJAX Unless Tab is Closed
http://code.google.com/p/chromium/issues/detail?id=52411

+dcarney

chro...@googlecode.com

unread,
Mar 5, 2013, 11:03:19 PM3/5/13
to chromi...@chromium.org

Comment #47 on issue 52411 by fuz...@gmail.com: AJAX Memory Leak - Chrome
Never Releases Memory Consumed by AJAX Unless Tab is Closed
http://code.google.com/p/chromium/issues/detail?id=52411

This is very easy to repeat:

while(1) {
var xhr = new XMLHttpRequest();
}

will blow up within seconds. Same thing happens with mutation observers:

while(1) {
var observer = new MutationObserver(function() {});
}


--
You received this message because this project is configured to send all
issue notifications to this address.
You may adjust your notification preferences at:
https://code.google.com/hosting/settings

chro...@googlecode.com

unread,
Mar 6, 2013, 5:28:48 AM3/6/13
to chromi...@chromium.org

Comment #48 on issue 52411 by tony.val...@perigonnetworks.com: AJAX Memory
Leak - Chrome Never Releases Memory Consumed by AJAX Unless Tab is Closed
http://code.google.com/p/chromium/issues/detail?id=52411

Wow! After 2.5 years, no Google engineers can figure out a little memory
leak?

chro...@googlecode.com

unread,
Jun 26, 2013, 7:41:21 PM6/26/13
to chromi...@chromium.org

Comment #53 on issue 52411 by parag.ma...@gmail.com: AJAX Memory Leak -
Chrome Never Releases Memory Consumed by AJAX Unless Tab is Closed
http://code.google.com/p/chromium/issues/detail?id=52411

A few seconds after I turn on the Developer Tools' Console pane is when JS
Script error appears in the toolbar. This is after closing Chrome.

Using Version 27.0.1453.116

chro...@googlecode.com

unread,
May 9, 2014, 2:45:05 AM5/9/14
to chromi...@chromium.org
Updates:
Labels: Cr-Blink-XHR

Comment #54 on issue 52411 by yhi...@chromium.org: AJAX Memory Leak -
Chrome Never Releases Memory Consumed by AJAX Unless Tab is Closed
http://code.google.com/p/chromium/issues/detail?id=52411

(No comment was entered for this change.)

chro...@googlecode.com

unread,
Aug 21, 2014, 12:22:32 PM8/21/14
to chromi...@chromium.org

Comment #56 on issue 52411 by samakata...@gmail.com: AJAX Memory Leak -
Chrome Never Releases Memory Consumed by AJAX Unless Tab is Closed
http://code.google.com/p/chromium/issues/detail?id=52411

The issue is still observed in Chrome 36.0.1985.143 m, however only on
Windows, not on Linux or OS X. Reproducible with the attached script even
loaded from the local file system, no server is needed.

Attachments:
chrome-xhr-mem-leak.html 623 bytes

chro...@googlecode.com

unread,
Aug 22, 2014, 8:14:34 AM8/22/14
to chromi...@chromium.org

Comment #57 on issue 52411 by phistuck: AJAX Memory Leak - Chrome Never
Releases Memory Consumed by AJAX Unless Tab is Closed
https://code.google.com/p/chromium/issues/detail?id=52411

In order to eliminate any rational of 'a foreground windows consumes more
memory', I changed your test case not to use setTimeout (a background tab
clamps setTimeout to one second). The leak is still reproducible (even
more, since the frequency increased), in a background or a foreground tab.

@japhet - you are the owner of the issue. Are you working on it? If so,
perhaps change the status to Available and move yourself to the CC list?

Attachments:
chrome-xhr-mem-leak.html 677 bytes

chro...@googlecode.com

unread,
Oct 6, 2014, 9:12:04 PM10/6/14
to chromi...@chromium.org

Comment #58 on issue 52411 by david.v...@gmail.com: AJAX Memory Leak -
Chrome Never Releases Memory Consumed by AJAX Unless Tab is Closed
https://code.google.com/p/chromium/issues/detail?id=52411

We're still seeing this in (stable) Chromium 37 on Linux, and probably
(stable) Chrome 37 on Windows.
It seems to be associated with varying the URL (e.g. by a query-string
param) across the repeat requests. Not sure whether XHR caching or just
plain string caching/leaks might be involved. As above commenters note,
v8/webkit/blink should be free to use a bit of mem before GC, but GC should
eventually kick in and the tab(s) should not crash.
I'm surprised this is not being observed in ChromeOS where people are
likely sitting in the same tab(s) all day?

chro...@googlecode.com

unread,
Oct 7, 2014, 10:52:11 PM10/7/14
to chromi...@chromium.org

Comment #59 on issue 52411 by fuzzy...@gmail.com: AJAX Memory Leak - Chrome
Never Releases Memory Consumed by AJAX Unless Tab is Closed
https://code.google.com/p/chromium/issues/detail?id=52411

I started investigating this problem after finding leaks in a page that
issues a regular one second GET request to a fairly large URL. My page is
intended for permanent display, not for ordinary web browsinI started
investigating this problem after finding leaks in a page that issues a
regular one second GET request to a fairly large URL. My page is intended
for permanent display, not for ordinary web browsing - so this leak became
apparent fairly rapidly during my testing. I have been able to reproduce
this problem under Linux by varying the URL each time a request is issued.
Please find attached:
* An updated chrome-xhr-mem-leak that increases the rate of the leak, and
includes a leak enable/disable button for a/b testing
* Two records of my running the leaking and non-leaking versions
concurrently on my machine. The slow leak version uses a short URL. The
fast leak version adds approximately 1kB of padding to the URL in each
request. The rate of the leak appears to be correlated to the size of the
URL

My findings are that this is a Private Memory leak rather than a leak
within the javascript memory. The javascript memory is stable throughout
the test. There is a lot of noise in the memory graphs so a sustained run
is advisable to reproduce the leak behaviour, and it is useful to have the
non-leaking version running at the same time as a control for comparison
purposes.

The memory statistics I have included in the graphs are the VMSize and
VmRSS readings from /proc/$pid/status. The VmRSS figure tracks closely with
the Private Memory figure reported by the Task manager.

A short description of the test runs follows:
* The slow leak case which does not include the 1k of padding in the URL
stabilised at approximately 1.5GB VmSize and 415MB VmRSS when querying the
same URL each request. When querying a different URL it grew steadily up to
a VmSize of about 4GB and VmRSS of about 2.7GB before my machine started to
have trouble running it at around the 9 hour mark. The test ended when the
tab died at around 11 hours of runtime.
* The fast leak case which does include the 1k of padding in the URL
stablised at a similar VmSize and VmRSS to the slow leak case. Querying a
different URL in each request caused it to grow to a size my machine was
having trouble with this time in only g - so this leak became apparent
fairly rapidly during my testing. I have been able to reproduce this
problem under Linux by varying the URL each time a request is issued.
Please find attached:
* An updated chrome-xhr-mem-leak that increases the rate of the leak, and
includes a leak enable/disable button for a/b testing
* Two records of my running the leaking and non-leaking versions
concurrently on my machine. The slow leak version uses a short URL. The
fast leak version adds approximately 1kB of padding to the URL in each
request. The rate of the leak appears to be correlated to the size of the
URL

My findings are that this is a Private Memory leak rather than a leak
within the javascript memory. The javascript memory is stable throughout
the test. There is a lot of noise in the memory graphs so a sustained run
is advisable to reproduce the leak behaviour, and it is useful to have the
non-leaking version running at the same time as a control for comparison
purposes.

The memory statistics I have included in the graphs are the VMSize and
VmRSS readings from /proc/$pid/status. The VmRSS figure tracks closely with
the Private Memory figure reported by the Task manager.

A short description of the test runs follows:
* The slow leak case which does not include the 1k of padding in the URL
stabilised at approximately 1.5GB VmSize and 415MB VmRSS when querying the
same URL each request. When querying a different URL it grew steadily up to
a VmSize of about 4GB and VmRSS of about 2.7GB before my machine started to
have trouble running it at around the 9 hour mark. The test ended when the
tab died at around 11 hours of runtime.
* The fast leak case which does include the 1k of padding in the URL
stablised at a similar VmSize and VmRSS to the slow leak case. Querying a
different URL in each request caused it to grow to a size where it
self-terminated in the course of one hour.

Graphing the contents of the attached CSV files shows the problem quite
well.

Attachments:
chrome-xhr-mem-leak-linux.html 1.5 KB
Linux memory slow leak.csv 195 KB
Linux memory fast leak.csv 90.5 KB

chro...@googlecode.com

unread,
Oct 7, 2014, 10:59:11 PM10/7/14
to chromi...@chromium.org
Updates:
Cc: hirosh...@chromium.org

Comment #60 on issue 52411 by kou...@chromium.org: AJAX Memory Leak -
Chrome Never Releases Memory Consumed by AJAX Unless Tab is Closed
https://code.google.com/p/chromium/issues/detail?id=52411

+hiroshige@

Do you think this is related to crbug.com/413358 ?

chro...@googlecode.com

unread,
Nov 13, 2014, 8:29:07 AM11/13/14
to chromi...@chromium.org

Comment #62 on issue 52411 by hirosh...@chromium.org: AJAX Memory Leak -
Chrome Never Releases Memory Consumed by AJAX Unless Tab is Closed
https://code.google.com/p/chromium/issues/detail?id=52411

I suspect this is because URLs (each >1KB) accumulates in
ResourceFetcher::m_validatedURLs.
From codesearch, strings are added to m_validatedURLs but never removed
from it, until ResourceFetcher is destructed.

chro...@googlecode.com

unread,
Nov 14, 2014, 3:50:31 AM11/14/14
to chromi...@chromium.org

Comment #63 on issue 52411 by hirosh...@chromium.org: AJAX Memory Leak -
Chrome Never Releases Memory Consumed by AJAX Unless Tab is Closed
https://code.google.com/p/chromium/issues/detail?id=52411

ResourceFetcher::m_validatedURLs seems to contain the only remaining
references to URL Strings, and by clearing m_validatedURLs resolved the
memory bloat:
https://codereview.chromium.org/723423002/

I tested on Linux (Chromium revision 303998), and the memory consumption
reported by Chromium Task Manager (when "Sent XHR: 300000") was
- without this CL: ~470MB
- with this CL: ~100MB
(I'm not completely sure about the correctness of this CL though)

chro...@googlecode.com

unread,
Nov 14, 2014, 7:35:52 AM11/14/14
to chromi...@chromium.org

Comment #65 on issue 52411 by bugdro...@chromium.org: AJAX Memory Leak -
Chrome Never Releases Memory Consumed by AJAX Unless Tab is Closed
https://code.google.com/p/chromium/issues/detail?id=52411#c65

The following revision refers to this bug:
http://src.chromium.org/viewvc/blink?view=rev&rev=185369

------------------------------------------------------------------
r185369 | hiro...@chromium.org | 2014-11-14T12:11:13.869868Z

Changed paths:
M
http://src.chromium.org/viewvc/blink/trunk/Source/core/fetch/ResourceFetcher.cpp?r1=185369&r2=185368&pathrev=185369

Clear ResourceFetcher::m_validatedURLs if too many entries are added

This is to avoid memory bloat due to m_validatedURLs.

BUG=52411

Review URL: https://codereview.chromium.org/723423002
-----------------------------------------------------------------

chro...@googlecode.com

unread,
Nov 16, 2014, 7:26:44 PM11/16/14
to chromi...@chromium.org
Updates:
Status: Fixed
Owner: hirosh...@chromium.org

Comment #66 on issue 52411 by kou...@chromium.org: AJAX Memory Leak -
Chrome Never Releases Memory Consumed by AJAX Unless Tab is Closed
https://code.google.com/p/chromium/issues/detail?id=52411

(No comment was entered for this change.)

Reply all
Reply to author
Forward
0 new messages