views:

47

answers:

2

I have a WCF service that I am calling to using jQuery 1.4.2 (polling it actually every second or so). Over time, the ajax calls slow. Initial request to a method are around ~30ms, but over about a half hour i can watch using Opera's DragonFly (and verified with chrome's tools too) my request times slowly increase. In about a half hour i go from ~30ms request time to ~300ms request time.

At first i thought it was the service i wrote, so I changed the method to just return a value, no calculations or anything:

public int DoSomething(int id)
    {
        return 0;
    }

I was pretty surprised to see that the behavior is the same: A steady increase in request time. I know this is pretty vague, but any pointers for trouble shooting something like this? if its not my method, who is the likely candidate?

Im using .NET 3.5sp1 & C#

edit: To clarify, I am using jQuery's $.ajax method to make the call, and its the actual request time that is slowing, the response is always pretty much ~0ms.

edit 2: I have fixed the memory issue mentioned in the comments with Jon Hanna & still my request times grow.

A: 

Have you looked at the memory being consumed by the browser as it goes on? It might be worth keeping an eye on this, and see if it increases much as time goes on.

You'll want a fresh browser (no point measuring after you've had your YouTube videos of your favourite musician's popular hits open in different tabs) that's been allowed to climb through any initial memory-grabs and then runs your script.

If this is an issue, then look at pooling your javascript objects, especially the XHR itself, at making sure events aren't bound to handlers and then ignored, and that you aren't continually adding to the DOM of the host document.

Jon Hanna
The browser memory is going up, but i dont know if its significant. ~3.5MB in about ~35-40min. jQuery is the one controlling the actual ajax request using its $.ajax method.
Mike_G