Skip to content Skip to sidebar Skip to footer

Android Surfaceview Threads And Memory Leaks

Im creating a game in android, and i noticed that the game has a memory leak. Iv managed to isolate the memory leak into a smaller application so that i can see well try and work o

Solution 1:

You should not create new Thread in the constructor when you are creating it in onSurfaceCreated. Compare your code to my example: How can I use the animation framework inside the canvas?

Solution 2:

As you can see here:

http://developer.android.com/resources/articles/avoiding-memory-leaks.html

The easiest way to start a memory leak in Android is to pass a view's constructor the whole activity instead of the application context. Have you try to change this line:

setContentView(newMemoryLeak(this));

into this one:

setContentView(new MemoryLeak(Context.getApplicationContext()));

?

Hope it helps.

Post a Comment for "Android Surfaceview Threads And Memory Leaks"