2014-06-15 2 views
1

이 coffeescript 코드 (레일 서버)로 인해 미도리는 더 많은 메모리를 사용하게되므로 분명히 메모리 누수가 발생합니다. 이것은 몇 시간 후에 내 pi가 충돌하게 만듭니다. 아무도 누출 원을 식별하는 데 도움을 줄 수 있습니까?라스베리 파이 자바 스크립트 메모리 누수

jQuery -> 
    title = "" 
    dir = "" 
    window.setInterval -> 
     $.get('p_status', (response) -> 
       title = jQuery.parseJSON(response.title) 
       dir = jQuery.parseJSON(response.dir) 
       $("#current_title").html(title) 
       $("#main_c").attr("src", dir)) 
    , 8000 

나는 또한 아무 소용, 다음 코드를 시도 .. :

jQuery -> 
    title = "" 
    dir = "" 
    ref_current_title = $("#current_title") 
    ref_main_c = $("#main_c") 
    window.setInterval -> 
     $.get('p_status', (response) -> 
       title = jQuery.parseJSON(response.title) 
       dir = jQuery.parseJSON(response.dir) 
       ref_current_title.html(title) 
       ref_main_c.attr("src", dir)) 

편집 : 완성도, 생성 된 자바 스크립트 :

(function() { 
    jQuery(function() { 
    var title, dir, ref_current_title, ref_main_c ; 
    title = ""; 
    dir = ""; 
    ref_current_title = $("#current_title"); 
    ref_main_c = $("#main_c"); 
    return window.setInterval(function() { 
    return $.get('p_status', function(response) { 
     title = jQuery.parseJSON(response.title); 
     dir = jQuery.parseJSON(response.dir); 
     ref_current_title.html(title); 
     return ref_main_c.attr("src", dir); 
    } 
    }); 
}, 8000); 
}); 

}).call(this); 
+0

그래서 레일 서버는 라즈베리 파이에? 그리고이 클라이언트 측 코드를 사용하여 8 초마다 서버를 폴링합니까? 따라서 메모리 누출은 레일 코드 내에 있어야합니다. 무엇을 배포하고 있습니까? 레일 작업자 프로세스는 몇 개입니까? 확실히 승객에게 배치하지 않고 한 명 이상의 직원을 고용하지 않을 것입니다. 바람직하게는 실제 스레딩을 위해 puma 및 rubinius와 같은 일부 다중 스레드 배치 서버를 사용합니다. 대부분의 응용 프로그램 서버에는 최대 메모리 구성이 있습니다.이 메모리 구성은 한계에 도달 한 후 레일 프로세스를 다시 시작합니다. –

+0

레일 서버와 미도리는 모두 동일한 나무 딸기 파이에 있습니다. 메모리를 누적하는 것이 미도리 프로세스입니다. – droelandt

답변

0

레일 서버 모두와 미도리는 같은 나무 딸기 파이에있다. 메모리를 누적하는 것은 미도리 프로세스입니다.

단지 이론이지만, 모든 간격 실행에 대해 새로운 익명의 기능을 생성하는 중일 수 있습니다. 그리고 그것은 쓰레기를 수집하지 않습니다.

나는 간격 루프의 외부 기능을 추출하려고 할 것이다, 그래서 한 번만 정의되어 :

get_p_status = 
() -> 
    $.get('p_status', (response) -> 
     title = jQuery.parseJSON(response.title) 
     dir = jQuery.parseJSON(response.dir) 
     $("#current_title").html(title) 
     $("#main_c").attr("src", dir) 
) 


jQuery -> 
    title = "" 
    dir = "" 
    window.setInterval get_p_status, 8000 
관련 문제