I am trying to use GLSurfaceView
on Android and experiencing problems.
I am using the code from this OpenGL article.
It works well but when I rotate the device, I notice that the allocated memory is growing.
So I use MAT to check if I have a memory leak and found that there are multiple Activity
instances there. If I use dominator tree, I found multiple GLThread
objects (but only one is running).
So is this an android GLSurfaceview
bug or I'm misunderstanding something about GLSurfaceView
?
This is commonly caused by referring to the Activity
context instead of referring to the Application
context. When referring to context
, always use getApplicationContext()
inside the Activity
. Avoid using this
(inside the Activity
) class as it refers to the Activity
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With