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. Dismiss Notice

Increasing RAM value ?

Discussion in 'Android' started by noskurt, May 12, 2014.

  1. noskurt

    noskurt

    Joined:
    May 7, 2014
    Posts:
    9
    My app RAM value is increase continuous. Its 45-75-110-165-210 MB. and it is shuting down itself. Because full of ram. I suspect memory leak but i dont do anything. Please help me . my unity verison is 4.3.4f Free version.
     
  2. Diviner

    Diviner

    Joined:
    May 8, 2010
    Posts:
    677
    Refrain from using static variables.
     
  3. noskurt

    noskurt

    Joined:
    May 7, 2014
    Posts:
    9
    I just use one static var. Its interesting.
     
  4. Diviner

    Diviner

    Joined:
    May 8, 2010
    Posts:
    677
    Depending on what type that var is, it could be the source of your problems. Flush all static data between scene loads.
     
  5. noskurt

    noskurt

    Joined:
    May 7, 2014
    Posts:
    9
    I cleared all static var. but still increasing RAM.
     
  6. noskurt

    noskurt

    Joined:
    May 7, 2014
    Posts:
    9
    what can i do another
     
  7. Diviner

    Diviner

    Joined:
    May 8, 2010
    Posts:
    677
    If you're using DontDestroyOnLoad without caution, it can also lead to Memory Leaks.
     
  8. noskurt

    noskurt

    Joined:
    May 7, 2014
    Posts:
    9
    No. I dont use anything about DontDestroyOnLoad. Every script very simple . I dont understand. :(
     
  9. Madhawk

    Madhawk

    Joined:
    Mar 14, 2014
    Posts:
    5
    Does the memory increase when you change scenes? Sometimes Unity doesn't kill all the objects on loading from one scene to another and if you change scenes several times the memory increases a lot. If this is the case, you could try to move to an empty scene before going to your real destination. Additionally, you could call Resources.UnloadUnusedAssets just for sure.
     
  10. noskurt

    noskurt

    Joined:
    May 7, 2014
    Posts:
    9
    I have 3 scene but ram increasing only on one scene. I use Resources.UnloadUnusedAssets on everyscene. But i didnt get a result. I'm about to go crazy :mad:
     
  11. Madhawk

    Madhawk

    Joined:
    Mar 14, 2014
    Posts:
    5
    Yes, but the memory increases when you change scenes or even when you stay on this scene?
     
  12. noskurt

    noskurt

    Joined:
    May 7, 2014
    Posts:
    9
    I tested my game. When I pause my game, I contol ram value. Every time increase ram value on one scene.
     
  13. Madhawk

    Madhawk

    Joined:
    Mar 14, 2014
    Posts:
    5
    Are you sure you're not creating something on Update or FixedUpdate that you don't destroy?
     
  14. noskurt

    noskurt

    Joined:
    May 7, 2014
    Posts:
    9
    Code (csharp):
    1. function Update () {
    2. //  Debug.Log(System.GC.GetTotalMemory(false));
    3.  
    4.  
    5.     if (Input.GetKeyDown(KeyCode.Mouse0)) {
    6.    
    7.         rigidbody2D.velocity=Vector3(0,5,0);
    8.         audio.PlayOneShot(touch);
    9.        
    10.     }
    11.    
    12.     if (Input.GetKeyDown(KeyCode.LeftArrow)) {
    13.    
    14.         rigidbody2D.AddForce(Vector3.left*40);
    15.    
    16.     }
    17.    
    18.     if (Input.GetKeyDown(KeyCode.RightArrow)) {
    19.    
    20.         rigidbody2D.AddForce(Vector3.right*40);
    21.    
    22.     }
    23.    
    24. }
    25. function FixedUpdate()
    26. {
    27.  
    28.     if (Input.acceleration.z<0) {
    29.             rigidbody2D.velocity.x=(Input.acceleration.x)*400*Time.deltaTime;
    30.     }
    31.    
    32.     else if (Input.acceleration.z>0) {
    33.         if (Input.acceleration.x<0) {
    34.             rigidbody2D.velocity.x=(Input.acceleration.x)*400*Time.deltaTime;
    35.         }
    36.         else if (Input.acceleration.x>0){
    37.             rigidbody2D.velocity.x=(Input.acceleration.x)*400*Time.deltaTime;
    38.         }
    39.     }  
    40.  
    41. }
    42.  
    I have two playerprefs in somewhere. I think it isnt matter. Do you?
     
  15. Madhawk

    Madhawk

    Joined:
    Mar 14, 2014
    Posts:
    5
    It isn't the playerprefs. It´s overwritten.
    Where do you create this rigidbody? Where do you destroy it?
     
  16. noskurt

    noskurt

    Joined:
    May 7, 2014
    Posts:
    9
    This rigidbody is attached to my character. so its one in scene. when scene is open, creating rigidbody. I dont destroy this.
     
  17. Agent_007

    Agent_007

    Joined:
    Dec 18, 2011
    Posts:
    899
    Do you edit/create materials during runtime?