Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Have a look at our Games Focus blog post series which will show what Unity is doing for all game developers – now, next year, and in the future.
    Dismiss Notice

How to solve High CPU usage in background?

Discussion in 'BlackBerry' started by ARY-PRODUCTION, Sep 2, 2014.

  1. ARY-PRODUCTION

    ARY-PRODUCTION

    Joined:
    Aug 15, 2014
    Posts:
    5
    I have developed only GUI application in Unity4.5.2f1 ,
    but I noticed high cpu usage when my app in background.

    Specifically,if in my code...

    Code (CSharp):
    1.     void Update(){
    2.         if(!paused){
    3.             //brabrabra...
    4.         }
    5.     }
    6.     void OnGUI(){
    7.         if(!paused){
    8.             //brabrabra
    9.         }
    10.     }
    11.     void OnApplicationPause(bool pauseStatus){
    12.         if(pauseStatus){
    13.             paused=true;
    14.             Time.timeScale=0;
    15.         }else{
    16.             paused=false;
    17.             Time.timeScale=1;
    18.         }
    19.     }
    20.  
    I could check that OnApplicationPause is worked,
    but CPU usage is around 45% !!!
    This app drained my battery.

    Ofcause I checked out "Run in background",
    if check in this,CPU usage up to over 60%.

    Any suggestions?
     
  2. ARY-PRODUCTION

    ARY-PRODUCTION

    Joined:
    Aug 15, 2014
    Posts:
    5
    It solved by myself ,thanks.
     
  3. leewang2502

    leewang2502

    Joined:
    Jan 19, 2015
    Posts:
    8
    Dear ary Production, how to solve this?
     
  4. domcylai

    domcylai

    Joined:
    Mar 28, 2019
    Posts:
    4
    Can you share how you solved it?
    The solution I can think of now is that when I want to hide the unity program in the background, I actually change its parent window as the main window and change its window size to 0, but this is not the fundamental solution