My javascript client makes a JSONP request via the JQuery $.ajax() method every second. When I view the JavaScript console in Google chrome (13.0.782.215 m Windows) and click on the Resources button I can see that every second an item is added to the Scripts. This item is the result of my JSONP request, it looks like this:
jQuery162007347695156931877_1314625724397({"Online": "True"})
These items just keep building up; the longer the page stays alive, the longer the list becomes. My question is how do I clean up these resources?
I have seen a lot of similar questions here, but most relate to some sort of memory leak relating to using JQuery for DOM manipulation. As far as I know I am not doing these things. Other questions relate to some vague memory leak issue which does not seem easy to trace down. (e.g. here) I couldn't find a satisfying answer to this question as of yet, so I decided to post it.
I am not on some quest trying to trace down a vague memory leak, I just want to know why these JSONP request results are stacking up in Google Chrome, and of course, how to clean it all up.
I have a code snippet that will reproduce the issue:
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<script src="http://code.jquery.com/jquery-latest.js"></script>
<script type="text/javascript">
$(document).ready(function()
{
$.ajaxSetup({
// url: [edit:] I have removed the link since the question is answered now
crossdomain: true,
dataType: "jsonp",
tiemout: 3000,
success: myResult
});
function myRequest()
{
$.ajax();
}
function myResult(data, textStatus, jqXHR)
{
// do nothing
}
setInterval(myRequest, 1000);
});
</script>
</head>
<body>
</body>
</html>