Android Surfaceview Threads and memory leaks

久未见 提交于 2019-12-03 00:14:29
Lumis

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?

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(new MemoryLeak(this));

into this one:

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

?

Hope it helps.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!