Chromium memory processing

I am running a web application on Raspberry Pi in Chrome , which should work 24 hours a day. The main problem is that it runs from memory and displays "He is dead Jim . " I am wondering if anyone can help me:

  • Direct me to the chrome extension, which will reload / reload the browser if the memory runs out.
  • Provide a possible cron job to detect when memory is running out and restart the browser if this event

The goal is to chrome every day without human intervention. Therefore, any additional methods / ideas will be appreciated. Thanks in advance!

+4
source share
1 answer

I actually found the culprit in that he had several ajax requests, each of which ran every few seconds to check whether the server is still or not (this is a long story, but it needs to be done). Then I found a small solution to save memory on the Internet: put all ajax requests into a variable, and then clear the variable after use (I also cleared java-script unused variables for all applications). The following is an example:

   function getData(){
        var request = $.ajax({
                url : "/someurl",
                type : "HEAD",
                dataType : "json",
                success : function(data) {
                    //use your data
                }
                error: function(){
                //doSomething
                },
                cache : false
            });


        //HERE IS THE HACK! :)
        data = null;
        request.onreadystatechange = null;
        request.abort = null;
        request = null;
        }

      setTimeout(function(){
         getData();
     }, 0.05 * 60 * 1000)
}

PS I found the code online.

+3
source

Source: https://habr.com/ru/post/1534789/


All Articles