Ajax memory leak

I experience a slow memory leak in IE and Firefox using a combination of ASP.NET AJAX and jQuery. My scenario is very similar to the one described here: Preventing AJAX memory leaks , with the exception of using jquery and asp.net AJAX, not the prototype: I have a webpage that displays data in UpdatePanel which is updated every 60 seconds using a timer. in the AJAX javascript pageLoad function, which is called for each partial postback, I bind the events because they get lost in the asp.net partial postback:

function pageLoad(sender, args) { $("#item").unbind(); $("#item").hover( function() { // do something }, function() { // do something }); } 

therefore it is called every 60 seconds. Could this be causing a memory leak?

+1
source share
2 answers

Do this instead:

 $(function() { //.ready shortcut... $("#item").live("hover", function() { // do something }, function() { // do something }); }); 

Please note: this one requires jQuery 1.4.1 , but it works very differently in terms of memory. It attaches to the entire DOM, making sure the event bubbles up instead of attaching a new event to every object that you insert every 60 seconds.

+2
source

Yes it can be.

The first thing to try is to take the two functions defined there (if possible) and place them at a higher level so that they are defined only once.

0
source

Source: https://habr.com/ru/post/890358/


All Articles