Application crashes after seven hours !

I have a simple application that It needs to run for 10 hours per day. Don't ask why!!! I am not a programmer so i am not really aware about what happens with memory management variables or background logs in unity. I have some gui variables like that ... there are loads more to be honest ..

var widthBorderShort = (Screen.width - (Screen.width/20))-512;
        var widthBorderLong = (Screen.width - (Screen.width/20))-975;
        var heightBorder = (Screen.height -(Screen.height/20))-64;

If i declare the variables in OnGUI and do a debug log the variables are called every frame. How unity is working if i am not using debug log? does it just replaces a few numbers every frame or it keeps a log of them? In around 7 hours the application crashes ! So i must have a memory leak or some sort of logging overflow ... Is there any way to figure out what is going on ? IT might be even a computer problem ...

The ideal would have been to put these variables in an update or onGUI and calculate screen.width ONLY when the user tries to resize. something like

   if (application.resize) 
    {
    //find my new screen/width   
//dostuff  
    }

or getting a value from awake naming it initialScreenWidth and

        if (Screen.width> intialScreenWidth){
    //declare variables 
    initialScreenWidth= Screen.width;
//do stuff 
    }

Should i worry about declaring variables OnGUI or there is no problem ... ?I am not sure where to begin really ... any suggestions?

None of the lines of code you show should allocate any amount of memory that matters. They are integers, not objects, and you are allocating them in local variables in OnGUI- they go away when the method exits.

The kinds of lines you should be worried about allocate objects that don't get cleaned up. They would tend to be game objects stored in the scene (for example, if you called Instantiate) or objects added to arrays, text being appending to a string over and over again... something like that.

If you haven't already, verify that memory allocation is in fact the problem. Run your app the same way it's being run when it crashes, and monitor it (on Mac use Activity Monitor, on Windows use Task Manager.) If memory is the problem you should see the memory footprint go up significantly after half an hour. There are many reasons an application can to crash, for example, if it accesses a network or network resource that gets shut down every night.

If you have any specifics about the crash you should post them. Try reproducing with a debug build, maybe you'll get some better information from the crash.