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.
Refrain from using static variables.
I just use one static var. Its interesting.
Depending on what type that var is, it could be the source of your problems. Flush all static data between scene loads.
I cleared all static var. but still increasing RAM.
what can i do another
If you’re using DontDestroyOnLoad without caution, it can also lead to Memory Leaks.
No. I dont use anything about DontDestroyOnLoad. Every script very simple . I dont understand.
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.
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 :@
Yes, but the memory increases when you change scenes or even when you stay on this scene?
I tested my game. When I pause my game, I contol ram value. Every time increase ram value on one scene.
Are you sure you’re not creating something on Update or FixedUpdate that you don’t destroy?
function Update () {
// Debug.Log(System.GC.GetTotalMemory(false));
if (Input.GetKeyDown(KeyCode.Mouse0)) {
rigidbody2D.velocity=Vector3(0,5,0);
audio.PlayOneShot(touch);
}
if (Input.GetKeyDown(KeyCode.LeftArrow)) {
rigidbody2D.AddForce(Vector3.left*40);
}
if (Input.GetKeyDown(KeyCode.RightArrow)) {
rigidbody2D.AddForce(Vector3.right*40);
}
}
function FixedUpdate()
{
if (Input.acceleration.z<0) {
rigidbody2D.velocity.x=(Input.acceleration.x)*400*Time.deltaTime;
}
else if (Input.acceleration.z>0) {
if (Input.acceleration.x<0) {
rigidbody2D.velocity.x=(Input.acceleration.x)*400*Time.deltaTime;
}
else if (Input.acceleration.x>0){
rigidbody2D.velocity.x=(Input.acceleration.x)*400*Time.deltaTime;
}
}
}
I have two playerprefs in somewhere. I think it isnt matter. Do you?
It isn’t the playerprefs. It´s overwritten.
Where do you create this rigidbody? Where do you destroy it?
This rigidbody is attached to my character. so its one in scene. when scene is open, creating rigidbody. I dont destroy this.
Do you edit/create materials during runtime?