I have a javascript file with the content below.
"use strict";
$(function () {
var divs = $(".sc-frames");
var next = 0;
var currentIndex = 0;
var request = function (action, controller, div) {
var url = "../" + controller + "/" + action;
$.ajax({
type: "GET",
url: url,
dataType: "html",
async: false,
timeout:10000,
success: function (result) {
writeResponse(result, div);
},
error: function () {
$("#errorMessage").show();
}
});
};
var writeResponse = function (result, div) {
$(div).hide().html(result).slideDown("slow");
currentIndex = divs.index($(div));
if (parseInt(divs.length - 1) == parseInt(currentIndex)) {
next = 0;
} else {
next++;
}
};
var createRequest = function () {
$("#errorMessage").hide();
$(divs[currentIndex]).empty();
var div = divs[next];
var action = $(div).attr("data-action");
var controller = $(div).attr("data-controller");
request(action, controller, div);
};
setInterval(createRequest, 30000);
createRequest();
});
This just makes an ajax call to 3 controller action method and post the view to the divs in order and continously one after the other.
But when I checked the performance moniter in Google chrome dev tools, it showed a js memory leak. The Js heap size is slowly increasing.
Is there a way to find out where exactly the memory leak is?
Thanks in advance.