x


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?

more ▼

asked Sep 10 '10 at 04:42 PM

alexnode gravatar image

alexnode
984 27 32 49

(comments are locked)
10|3000 characters needed characters left

1 answer: sort voted first

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.

more ▼

answered Sep 10 '10 at 06:46 PM

Bampf gravatar image

Bampf
5.1k 8 20 49

Thanks Bampf. You know, it is not nice waiting for seven hours! I will post when I find what it is. Memory seems more or less the same. I don't use the network... and the instantiate is not leaking... I have to test in another computer tomorrow.

Sep 12 '10 at 02:15 PM alexnode
(comments are locked)
10|3000 characters needed characters left
Your answer
toggle preview:

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Topics:

x617
x344
x253
x71
x28

asked: Sep 10 '10 at 04:42 PM

Seen: 1061 times

Last Updated: Sep 10 '10 at 04:42 PM