Note that there are some explanatory texts on larger screens.

plurals
  1. POAndroid Game Leaking memory because of GLThread reference
    text
    copied!<p>Right now I'm developing a game in Android (OpenGL ES 1.1) and I'm seeing that whenever I create a new SurfaceView (GLView) its thread is created. That's ok. The problem comes when I want to finish the Activity that holds the SurfaceView (and go back to the menu). It seems that the activities are not released because each GLThread is referencing it. This may finish with an OOM error.</p> <p>Some MAT pictures:</p> <p><img src="https://i.stack.imgur.com/XYBiw.png" alt="The MarkitActivity represents each single instance of the Activity that deals with SurfaceView"> </p> <p><img src="https://i.stack.imgur.com/nUv2k.png" alt="The list of all the activities in memory"></p> <p><img src="https://i.stack.imgur.com/ZFKNT.png" alt="What is holding the Activities from GC"></p> <p>The first picture: the MarkitActivity represents each single instance of the Activity that deals with SurfaceView.</p> <p>The second picture: The list of all the activities in memory.</p> <p>The Third Picture: What is holding the Activities from GC.</p> <p>If any code is needed I will post it. Nevertheless I have already tried the following things:</p> <p>->Weak reference of the Activity Context to the renderer and to the surfaceview.</p> <p>->Application Context instead of Activity Context (in normal and weak mode).</p> <p>->Trying to stop (in a hard way) the thread (interrupt) and waiting for join (Which the program does it, but the thread does not care, it is still there...)</p> <p>->Trying without debugging, just in case in debugger mode the values changes (the MAT pictures are without debugger).</p> <p>->Trying the Activity as singleInstance mode. Weird results and errors everywhere.</p> <p>->onPause and onResume are correctly controlled for the view.</p> <p>Any hint, idea, question or help will be really appreciated. Thanks in advance!</p> <p>Carlos.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload