현재 웹 응용 프로그램을 만들고 있습니다. 사용자가 하루 종일 내 애플리케이션을 실행할 수 있어야하는 곳. 현재 일부 메모리 문제가 있습니다. 브라우저가 충돌하는 곳.자바 스크립트 메모리 관리 누수
function Module() {
var _me = this;
this.init = function(){
_me.setBindings(); // Using reference from Module instead of this
}
// All kind of functions
this.init();
}
내가 this
변경 : 내가 사용되었다 구조의이 종류이다.
$.modules.dynamic_static_webpage.prototype.addRedirect = function (anum, aeditor) {
$.prompt(
$.utils.getTranslation("Redirect"),
$.utils.getTranslation("Geef de URL op waar naar toe geredirect moet worden"),
$.proxy(function (num, editor, input) {
this.clearRedirect(editor);
var val = input.val();
if (val.indexOf("www") == 0) {
val = "http://" + val;
}
// Timeout needed, because otherwise the clear is not finished
setTimeout($.proxy(function (n, e, v) {
$.HTMLTexteditorField.setIframeSelectionHTML.call(e, "{CMS-REDIRECT" + n + "_" + v + "}");
this.redirectShow(n, v);
}, this, num, editor, val), 200);
}, this, anum, aeditor)
);
};
지금 나는
$.proxy
많이 추가했습니다 :
그래서 더 복잡한 상황은 (실제로 내 코드 기압의 일부이다)이있다. 어느 이상한 것 같습니다.
"범위 밖에서 범위를 사용하여 변수를 사용하고 있습니다." 나는 위의 코드로 다시 작성합니다. 나는이 같은 다른 사이트에서 봤는데,하지만 그것을 알아낼 수 없습니다 :이로는 메모리 누수를 방지하기 위해 올바른 방법 인 경우
는누군가 나를 설명 할 수 있습니까? 아니면 더 나은 해결책이 있습니까?