提交 096614a6 编写于 作者: L lpancescu 提交者: Daniel Beck

[JENKINS-10912] Use setInterval in refreshPart (#2539)

* [JENKINS-10912] Use setInterval in refreshPart

The current implementation of refreshPart creates a new closure every 5
seconds, which, in combination with XMLHttpRequest objects, results in a
significant memory leak in all major browsers. By using
window.setInterval to schedule periodic refreshes, only one closure per
id is created. Please see issue #10912 in the Jenkins tracker for
further details.

* Stop periodical calls if we can't find the div

* Don't check if isRunAsTest changed after page load
上级 423fca9c
......@@ -1486,6 +1486,7 @@ function expandTextArea(button,id) {
// refresh a part of the HTML specified by the given ID,
// by using the contents fetched from the given URL.
function refreshPart(id,url) {
var intervalID = null;
var f = function() {
if(isPageVisible()) {
new Ajax.Request(url, {
......@@ -1493,6 +1494,8 @@ function refreshPart(id,url) {
var hist = $(id);
if (hist == null) {
console.log("There's no element that has ID of " + id);
if (intervalID !== null)
window.clearInterval(intervalID);
return;
}
var p = hist.up();
......@@ -1505,22 +1508,14 @@ function refreshPart(id,url) {
Behaviour.applySubtree(node);
layoutUpdateCallback.call();
if(isRunAsTest) return;
refreshPart(id,url);
}
});
} else {
// Reschedule
if(isRunAsTest) return;
refreshPart(id,url);
});
}
};
// if run as test, just do it once and do it now to make sure it's working,
// but don't repeat.
if(isRunAsTest) f();
else window.setTimeout(f, 5000);
else intervalID = window.setInterval(f, 5000);
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册