I'm seeing the same problem described in Memory Leak When Pulling JSON from WEB.
I simply have a function that makes a jsonp ajax request periodically. My function is called by another function triggered by a setInterval.开发者_JAVA技巧
I see a memory leak in all broswers that I've tried, IE, Safari, FireFox. Something I see in the Safari script debugger is that each response to an ajax request is listed as a script in the drop down list in the script debugger window, as if there is some kind of script object not getting cleaned up.
I'm using jquery 1.6.2. It is a "long term" leak, not cleaned up after running for several minutes.
Any ideas what is causing this?
request: function ()
{
$.ajax({
url: <myurl>
dataType: "jsonp",
jsonp: "jsoncallback",
timeout: 5000,
cache: false,
beforeSend: function (xhr)
{
},
success: function (data, status, xhr)
{
},
error: function (xhr, status, error)
{
},
complete: function (req, status)
{
}
});
}
...
setInterval(request, 100);
The fact you're sending ajax request every 100 milliseconds is enough.
Be aware, setInterval(request, 100); - 100 does not mean seconds, but milliseconds. 1 second = 1000 miliseconds
As far as a jQuery leaks, see jQuery memory leak with DOM removal
There is a utility for finding memory leaks: http://www.outofhanwell.com/ieleak/Drip-0.5.exe
@genesis is correct too.
精彩评论