Skip to main content

Bug Tracker

Side navigation

#6388 closed bug ()

Opened April 01, 2010 08:50PM UTC

Closed November 11, 2010 11:09PM UTC

Last modified March 14, 2012 01:45AM UTC

$.getJSON memory leak with JSONP even on success

Reported by: tarad10 Owned by: tarad10
Priority: undecided Milestone: 1.4.3
Component: ajax Version: 1.4.2
Keywords: JSONP Cc:
Blocked by: Blocking:

I am running $.getJSON inside an interval every 10 seconds. The script is polling the twitter search JSON API. It is grabbing the first 50 tweets based on a search query and dumping them into a div with the prepend() function.

The code works fine, but the $.getJSON function is leaking. I have spent a great deal of time trying to figure out why, but it seems like something is fundamentally wrong with the garbage collection.

My searching lead me to this site: There is a mention of manually going into the script element and deleting all of the properties to force deallocation. I have implemented this into the uncompressed jQuery 1.4.2 include by adding these three lines directly after line 5027 (head.removeChild( script )):

for(var prop in script) {

deletes script[prop];


This seems to help in that I can see at least some memory get freed up (before it was never going down), but it has not fixed the problem entirely. Perhaps I have implemented it in the wrong place, because it does not seem to delete all the properties.

I am not sure if this is due to running it within an interval or some other issue with my code, but I can't seem to figure out why it is leaking. I appreciate any help you can offer.

Attachments (0)
Change History (7)

Changed September 28, 2010 08:28AM UTC by sharmila comment:1

I did face somewhat a similar issue.

We do a getJSON call and construct a dynamic table and this is triggered at regular intervals.

It poses heavy memory usage each time when the call happens. Tried to free out and remove all the dom elements before reallocating. Still this doesn't help. Can someone give a clue on this of where is the memory issue actually happening in IE.

Changed October 21, 2010 01:27AM UTC by snover comment:2

owner: → tarad10
priority: → undecided
status: newpending

Could you please provide a test case demonstrating this issue?

Changed November 11, 2010 11:09PM UTC by trac-o-bot comment:3

status: pendingclosed

Automatically closed due to 14 days of inactivity.

Changed November 15, 2010 06:36PM UTC by anonymous comment:4

Still having this problem as well!

Changed November 19, 2010 07:01AM UTC by snover comment:5

Changed July 05, 2011 12:44PM UTC by comment:6

I know that it's quite old, but the leak happens on 1.6.1 as well.

Test case is very easy:

    <title>Detect leak</title>
    <script type="text/javascript" src="jquery-1.6.1.js"></script>
  <script type="text/javascript">
    var doReload = function (iteration) {
      iteration -= 1;
      if (iteration < 0) {

        url : "",
        dataType : "jsnop"

      window.setTimeout(function () {
      }, 500);

    // Start the test

Open process explorer and look at the memory allocation. You'll clearly see a leak.

As a matter of facts, the leaks happens in IE every time you add and remove a script tag from the head. You'll get the same leak even if you don't use jQuery but add the script manually.

Hope you guys find a way to dispose a script tag correctly.

Changed July 05, 2011 01:26PM UTC by comment:7

BTW this is a duplicate of #8205