views:

65

answers:

2

I've seen some other posts on this, but it appears that when i do ajax calls with jquery over and over again (every 30 seconds in my case), I get a memory leak. Changing from a $get to a $post (whilst more secure as well) cuts down on the size - it still happens. Even if I do NOTHING in the response.

Any ideas anyone?

EDIT:

Here is the code - sorry for not including it the first time....

$.post("Home/GetDashboard", { monitorDate: monitorDate }, function(data) {
    $.each(data, function() {
         // this code has been removed to help isolate leak
    });  
}, 'json');

This will cause a memory leak each time of around 50 kb. That's give or take. I have a lot of DOM code in the $.each() function and when I include that, the memory leak jumps to about 100 kb with each call. I am calling this function every 30 seconds using jQuery timers.

I was using the $.getJSON method, but the memory leak with that was more like 300 kb (YIKES!)

+1  A: 

You need to determine which process is growing. If its ASP.NET then you can run a memory profiler such as ANTS. If your browser process is continuing to grow then you need to assess the DOM and find out what's happening with a tool like FireBug.

rick schott
Included the code in the edit. Unfortunately for me, I work for a business and we use IE exclusively, so whether or not it works in Firefox is irrelevant. I hate IE just as much as the next guy but it's got golden handcuffs on me.
Burke Holland
That doesn't make any sense though, if ASP.NET is somehow leaking, that would be reflected on the server, while the OP's problem is on the browser.
kprobst
A: 

We really need some evidence.

Can you include any stats & screen grabs? Which browsers & OS's are you talking about?

You also need to show some code, are you replacing large fragments of the DOM? (if your using crappy update panels wrapped around large forms then this is a real possibility!) If so how are you doing it?

What tool did you use to find the leak(s)?

Can you recreate the issue on jsbin or jsfiddle?

redsquare