Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6325751
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T16:57:17+00:00 2026-05-24T16:57:17+00:00

How long does openGL store a texture for? Does the texture memory get recycled

  • 0

How long does openGL store a texture for?

Does the texture memory get recycled when you leave an activity?

For example if I have the following code:

mGL.glGenTextures(1, mTextures, 0);
        mGL.glBindTexture(GL10.GL_TEXTURE_2D, mTextures[0]); // A bound texture is
                                                            // an active texture

        //mGL.glTexImage2D(GL10.GL_TEXTURE_2D, 0, GL10.GL_RGBA, bitmap.getWidth(),bitmap.getHeight(), 0, GL10.GL_RGBA, GL10.GL_FLOAT, textures);
        GLUtils.texImage2D(GL10.GL_TEXTURE_2D, 0,GL10.GL_RGBA, bitmap, 0);

        // create nearest filtered texture
        mGL.glTexParameterf(GL10.GL_TEXTURE_2D, GL10.GL_TEXTURE_MIN_FILTER,
                GL10.GL_LINEAR); // This is where the scaling algorithms are
        mGL.glTexParameterf(GL10.GL_TEXTURE_2D, GL10.GL_TEXTURE_MAG_FILTER,
                GL10.GL_LINEAR); // This is where the scaling algorithms are
        mGL.glTexParameterf(GL10.GL_TEXTURE_2D, GL10.GL_TEXTURE_WRAP_S,
                GL10.GL_CLAMP_TO_EDGE);
        mGL.glTexParameterf(GL10.GL_TEXTURE_2D, GL10.GL_TEXTURE_WRAP_T,
                GL10.GL_CLAMP_TO_EDGE);
        GLUtils.texImage2D(GL10.GL_TEXTURE_2D, 0, bitmap, 0);

        //bitmap.recycle();
        Log.v("GLSurfaceView", "Loading Texture Finished");
        return mTextures[0];

What changes will invalidate the return value?

I don’t want to reload all my textures when I come back into an activity (say the person had a phone call) because it really slows things down.

Update:

Found this info in the Renderer documentation, which confirms the answer given below by @svdree:

EGL Context Lost
There are situations where the EGL rendering context will be lost. This typically happens when device wakes up after going to sleep. When the EGL context is lost, all OpenGL resources (such as textures) that are associated with that context will be automatically deleted. In order to keep rendering correctly, a renderer must recreate any lost resources that it still needs. The onSurfaceCreated(GL10, EGLConfig) method is a convenient place to do this.

That means that the textures are related to the EGL Context

Since posting this question I have attempted to solve the problem by having my activities inherit from a base activity that has a reference to a custom GLRenderer. Basically, I can pass the OpenGLSurface View forward (i.e. make it instantiate it in one activity and use it in the next), but once it goes through its shutdown procedure it doesn’t start up again.

I have also found that making your activities transparent preserves the openGL context below the transparent activity (which makes sense, but helps only for menus and such). However I suppose it would be possible to always have every activity after the openGL activity be just a little bit transparent, thereby preserving the textures in the background across all your activities (this is probably what I will do)

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-24T16:57:18+00:00Added an answer on May 24, 2026 at 4:57 pm

    When you leave an activity, your OpenGL context will be lost, which means all your textures, vertex buffer objects etc. will need to be recreated. This is typically done in the onSurfaceCreated() method of the GLSurfaceView.Renderer class.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Long story short, I have a substantial Python application that, among other things, does
I have a long string (a DNA sequence). It does not contain any whitespace
How long does it take to declare a variable in C, for example int
How long does robotium wait for a new activity to show up? Is it
I have the above-mentioned error in s1=some very long string............ Does anyone know what
I have an application that does some long calculations, and I would like to
How long does it take for an experienced Windows programmer to learn writing simple
Why does Visual studio take so long to delete a file from the solution
How does the JVM handle a primitive long, which is 64bits, on a 32bit
What does Java do with long variables while performing addition? Wrong version 1: Vector

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.