Search Unity

  1. We are migrating the Unity Forums to Unity Discussions. On July 12, the Unity Forums will become read-only.

    Please, do not make any changes to your username or email addresses at id.unity.com during this transition time.

    It's still possible to reply to existing private message conversations during the migration, but any new replies you post will be missing after the main migration is complete. We'll do our best to migrate these messages in a follow-up step.

    On July 15, Unity Discussions will become read-only until July 18, when the new design and the migrated forum contents will go live.


    Read our full announcement for more information and let us know if you have any questions.

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