Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    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