Shawn D.
Shawn D.

Reputation: 8125

jQuery Ajax & Memory leak question

I have web app that does periodic scan operations, and on a specific page, shows the status of those operations (and any previously-completed ones). I have an Ajax request that I send using jQuery, and it returns the same page I'm currently on, modified given a time variable (last updated) to include just the running scans and any recently completed ones.

Apparently, after leaving this open overnight, which isn't a normal use case, on IE8 an 'out of memory at line 112' (nothing notable at line 112 in anything) was returned. I'm trying to figure out what I'm doing wrong, and where it could be leaking.

My question is: since I'm reloading the same page, but only taking a piece of it, are the 'ready' handlers getting rerun or something? For the most part, the active operations table is going to be empty, so it's not like I'm continually increasing the size of the table or something obvious.

function updateActiveScanList()
 {
    $.ajax({  
        method: "POST",
        url: "ScanList.action",
        data: { updatedTime: $('#updatedTime').val() },
        success: function(data) { 


        // Update the active scan list.
        $('#activescans').html( $("#activescans", data) );

        // the recent scans table update requires more massaging, omitted for brevity,
        // since there's nothing else done there, this happens even if nothing else is 
        // ever inserted.
    });
}
$(document).ready(

  function(){
      setInterval( updateActiveScanList, 30000 );
  } 
);

Upvotes: 2

Views: 998

Answers (1)

Dr.Molle
Dr.Molle

Reputation: 117314

You can use a tool like sIEve to detect the things that eat your memory.
I guess the number of used DOM-nodes(they don't need to be a part of the document-tree) will increase with every manipulation.

It would be the best if you forget jQuery for the part of the DOM-manipulation, the methods jQuery uses are known as prone to this issue, while they partial use some "dirty" things like innerHTML.

Can you give an example of what you like to have inside #activescans?

Upvotes: 4

Related Questions