2013-05-20 3 views
2

재무 메모리 누수가있는 코드 조각을 만들고 있는데, 예제 함수를 게시하고 있지만 전체 11,000 개의 코드에는 비슷한 기능이 반복되어 있습니다. 새로 고침 버튼을 클릭하면 평균 5MB 메모리 누수가 발생합니다. 새로 고침 버튼 뒤에있는 논리는 객체의 빈 함수를 호출하는 것입니다. 순환 참조 및 클로저에 대한 모든 조사한 있지만 빈 배열로 모든 것을 설정하는 방법이 올바른지 또는 모든 null로 설정해야하는지 정말 잘 모르겠습니다? 어떤 도움이라도 좋을 것입니다. 앱이 IE에 있기 때문에 IE를 사용해야합니다. 슬프게도 나를 위해 크롬 도구 없습니다 :(JavaScript 메모리 누출 문제

/** 
* 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

JS에서는'var myArray = new Array(); '를 사용하여 배열을 설정합니다. - http://www.w3schools.com/js/js_obj_array.asp –

+0

@DavidStarkey 리터럴은 괜찮습니다. – canon

+5

일반적인 방법은 * * 생성자의 의미가 일치하지 않기 때문에 적어도'Array' 생성자를 사용하지 마십시오. – Dancrumb

답변

3

/O는 방법 응용 프로그램을 디버깅하는 메모리 누수가 발생 방법 및 표시됩니다 구글 I에서이 비디오. http://www.youtube.com/watch?v=x9Jlu_h_Lyw

잡아 커피와 좋은위한 준비 비디오.

+0

죄송합니다. 이전에 Chrome을 사용할 수 없다고 언급 했어야합니다. 내 앱은 IE에 있습니다. – alyn000r

+3

그래서? Chrome에서 여전히 메모리 누수를 디버깅 할 수 있습니다. – Geuis

+1

참으로 흥미로운 비디오. – GameAlchemist