我正在编写一段有一个内存泄漏的代码,我发布了一个示例函数,但我的整个11,000行代码都有类似的函数重复遍历。单击“刷新”按钮时,我遇到平均5Mb的内存泄漏。刷新按钮背后的逻辑是调用对象的空函数。我已经研究了所有的循环引用和闭包但我不确定我将所有内容设置为空数组的方式是正确的还是我应该将所有内容设置为null?任何帮助都会很棒。我必须使用IE作为应用程序在IE上。可悲的是,对我来说没有镀铬工具:(
/**
* Represents the tasks for the currently loaded patients.
*/
var foo = {
loaded: false,
overdueTaskCounts: [],
unscheduledTaskCounts: [],
currentTaskCounts: [],
scheduled: null,
patientTasks: {},
tasks: {},
taskNumber: 0,
/**
* Unpacks the JSON received from the CareCompass service for the CareCompass task counts.
* @param reply - The JSON representing the data returned from the CareCompass service.
*/
unpack: function unpackTasks(reply) {
var taskCounts = reply.data; * * //This function populates the variables declared above**//
this.scheduled = taskCounts.scheduled;
},
/**
* Removes all the task information related to the loaded patients.
* @param none
*/
empty: function emptyTasks() {
this.loaded = false;
this.overdueTaskCounts = [];
this.unscheduledTaskCounts = [];
this.currentTaskCounts = [];
this.scheduled = null;
this.patientTasks = {};
}
}
答案 0 :(得分:3)
来自Google I / O的视频将向您展示内存泄漏的发生方式以及如何调试您的应用。 http://www.youtube.com/watch?v=x9Jlu_h_Lyw
拿一些咖啡,准备好制作精彩视频。