Android Surfaceview Threads and memory leaks

后端 未结 2 1579
青春惊慌失措
青春惊慌失措 2021-02-04 15:55

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 wor

2条回答
  •  抹茶落季
    2021-02-04 16:49

    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.

提交回复
热议问题