Click here to Skip to main content
15,891,473 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Hi,

Need a quick solution even if its a hack its fine
I am using a glSurfaceView in my android game I am developing
There are a some textures loaded and also using opengl for drawing some objects at runtime before rendering.

I have fixed 1 problem -- the surface was recreated whenever the activity in pause state and resumed, also when a different app was brought upfront. The issue here was, if i swapped b/w apps too many times the RAM usage went from 12mb to 40mb(each swap costs 5-6mb). The problem here was the surface was not destroyed since the context is not destroyed so the memory build up.

FIX - I am saving the surface and not destroying it at all unless the app is closed. Then reusing it. Its working fine for any opengl related transforms(drawing some shapes)

Current problem some what related -- when i apply texture it totally goes blank and if i recreate the surface then it will be applied. But the problem is memory build up and the surface is not getting destroyed.

FYI I am using the android code for surface view and a little tweak to create surface once only

Please some one help me to destroy the surface and release memory without destroying the context



Java
private void stopEglLocked()
    {
        //Destroying surface is not releasing the memory, so not destroying 
        //Surface is created only once during the activity lifetime
        /*
        if (mHaveEgl) {
            mHaveEgl = false;
            mEglHelper.destroySurface();
            sGLThreadManager.releaseEglSurface(this);
        }*/

    }
Posted

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900