4

When GLSurfaceView is Created, call GLES20.glGenTextures and then Every time a call GLES20.glDeleteTextures in GLThread, but sometimes, the gl_out_of_memory occurs. How do I solve this problem?

[Error Log]

02-18 11:44:04.317: W/Adreno-GSL(25831): <sharedmem_gpumem_alloc_id:1498>: sharedmem_gpumem_alloc: mmap failed errno 12 Out of memory
02-18 11:44:04.317: E/Adreno-GSL(25831): <gsl_memory_alloc_pure:2042>: GSL MEM ERROR: kgsl_sharedmem_alloc ioctl failed.
02-18 11:44:04.327: I/Timeline(25831): Timeline: Activity_idle id: android.os.BinderProxy@325bb5f9 time:1454439379
02-18 11:44:04.357: W/Adreno-GSL(25831): <sharedmem_gpumem_alloc_id:1498>: sharedmem_gpumem_alloc: mmap failed errno 12 Out of memory
02-18 11:44:04.357: E/Adreno-GSL(25831): <gsl_memory_alloc_pure:2042>: GSL MEM ERROR: kgsl_sharedmem_alloc ioctl failed.
02-18 11:44:04.357: W/Adreno-ES20(25831): <core_glTexImage2D:539>: GL_OUT_OF_MEMORY
02-18 11:44:05.197: E/qdmemalloc(25831): ion: Failed to map memory in the client: Out of memory
02-18 11:44:05.197: E/qdgralloc(25831): Could not mmap handle 0xa1fdaba0, fd=43 (Out of memory)
02-18 11:44:05.197: E/qdgralloc(25831): gralloc_register_buffer: gralloc_map failed
02-18 11:44:05.197: W/GraphicBufferMapper(25831): registerBuffer(0xa1fdaba0) failed -12 (Out of memory)
02-18 11:44:05.197: E/GraphicBuffer(25831): unflatten: registerBuffer failed: Out of memory (-12)
02-18 11:44:05.197: E/Surface(25831): dequeueBuffer: IGraphicBufferProducer::requestBuffer failed: -12
02-18 11:44:05.197: W/Adreno-EGLSUB(25831): <DequeueBuffer:720>: dequeue native buffer fail: Out of memory, buffer=0x0, handle=0x0
02-18 11:44:05.197: E/qdmemalloc(25831): ion: Failed to map memory in the client: Out of memory
02-18 11:44:05.197: E/qdgralloc(25831): Could not mmap handle 0xb3bcb380, fd=49 (Out of memory)
02-18 11:44:05.197: E/qdgralloc(25831): gralloc_register_buffer: gralloc_map failed
02-18 11:44:05.197: W/GraphicBufferMapper(25831): registerBuffer(0xb3bcb380) failed -12 (Out of memory)
02-18 11:44:05.197: E/GraphicBuffer(25831): unflatten: registerBuffer failed: Out of memory (-12)
02-18 11:44:05.197: E/Surface(25831): dequeueBuffer: IGraphicBufferProducer::requestBuffer failed: -12
02-18 11:44:05.197: W/Adreno-EGLSUB(25831): <DequeueBuffer:720>: dequeue native buffer fail: Out of memory, buffer=0x0, handle=0x0
02-18 11:44:05.197: W/Adreno-EGL(25831): <qeglDrvAPI_eglSwapBuffers:3702>: EGL_BAD_SURFACE
02-18 11:44:05.197: W/OpenGLRenderer(25831): swapBuffers encountered EGL_BAD_SURFACE on 0x877fea00, halting rendering...
02-18 11:44:06.207: A/libc(25831): Fatal signal 11 (SIGSEGV), code 1, fault addr 0x54 in tid 25848 (RenderThread)

[When surface is created, call glTexImage2D.]

    mProgram_y_texture = GLES20.glGetUniformLocation(mProgram, "y_texture");
    mYTextureHandle = new int[1];
    GLES20.glGenTextures(1, mYTextureHandle, 0);
    GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, mYTextureHandle[0]);
    GLES20.glTexImage2D(GLES20.GL_TEXTURE_2D, 0, GLES20.GL_RGBA, VIDEO_WIDTH, VIDEO_HEIGHT, 0, GLES20.GL_RGBA, GLES20.GL_UNSIGNED_BYTE, null);
    GLES20.glTexParameteri(GLES20.GL_TEXTURE_2D, GLES20.GL_TEXTURE_MIN_FILTER, GLES20.GL_LINEAR);
    GLES20.glTexParameteri(GLES20.GL_TEXTURE_2D, GLES20.GL_TEXTURE_MAG_FILTER, GLES20.GL_LINEAR);
    GLES20.glTexParameteri(GLES20.GL_TEXTURE_2D, GLES20.GL_TEXTURE_WRAP_S, GLES20.GL_CLAMP_TO_EDGE);
    GLES20.glTexParameteri(GLES20.GL_TEXTURE_2D, GLES20.GL_TEXTURE_WRAP_T, GLES20.GL_CLAMP_TO_EDGE);

    mProgram_u_texture = GLES20.glGetUniformLocation(mProgram, "u_texture");
    mUTextureHandle = new int[1];
    GLES20.glGenTextures(1, mUTextureHandle, 0);
    GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, mUTextureHandle[0]);
    GLES20.glTexImage2D(GLES20.GL_TEXTURE_2D, 0, GLES20.GL_RGBA, VIDEO_WIDTH/2, VIDEO_HEIGHT/2, 0, GLES20.GL_RGBA, GLES20.GL_UNSIGNED_BYTE, null);
    GLES20.glTexParameteri(GLES20.GL_TEXTURE_2D, GLES20.GL_TEXTURE_MIN_FILTER, GLES20.GL_LINEAR);
    GLES20.glTexParameteri(GLES20.GL_TEXTURE_2D, GLES20.GL_TEXTURE_MAG_FILTER, GLES20.GL_LINEAR);
    GLES20.glTexParameteri(GLES20.GL_TEXTURE_2D, GLES20.GL_TEXTURE_WRAP_S, GLES20.GL_CLAMP_TO_EDGE);
    GLES20.glTexParameteri(GLES20.GL_TEXTURE_2D, GLES20.GL_TEXTURE_WRAP_T, GLES20.GL_CLAMP_TO_EDGE);

    mProgram_v_texture = GLES20.glGetUniformLocation(mProgram, "v_texture");
    mVTextureHandle = new int[1];
    GLES20.glGenTextures(1, mVTextureHandle, 0);
    GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, mVTextureHandle[0]);
    GLES20.glTexImage2D(GLES20.GL_TEXTURE_2D, 0, GLES20.GL_RGBA, VIDEO_WIDTH/2, VIDEO_HEIGHT/2, 0, GLES20.GL_RGBA, GLES20.GL_UNSIGNED_BYTE, null);
    GLES20.glTexParameteri(GLES20.GL_TEXTURE_2D, GLES20.GL_TEXTURE_MIN_FILTER, GLES20.GL_LINEAR);
    GLES20.glTexParameteri(GLES20.GL_TEXTURE_2D, GLES20.GL_TEXTURE_MAG_FILTER, GLES20.GL_LINEAR);
    GLES20.glTexParameteri(GLES20.GL_TEXTURE_2D, GLES20.GL_TEXTURE_WRAP_S, GLES20.GL_CLAMP_TO_EDGE);
    GLES20.glTexParameteri(GLES20.GL_TEXTURE_2D, GLES20.GL_TEXTURE_WRAP_T, GLES20.GL_CLAMP_TO_EDGE);

[When surface is destroy, call glDeleteTextures.]

    GLES20.glActiveTexture(GLES20.GL_TEXTURE0);
    GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, mYTextureHandle[0]);
    GLES20.glDeleteTextures(1, mYTextureHandle, 0);
    GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, 0);

    GLES20.glActiveTexture(GLES20.GL_TEXTURE1);
    GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, mUTextureHandle[0]);
    GLES20.glDeleteTextures(1, mUTextureHandle, 0);
    GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, 0);

    GLES20.glActiveTexture(GLES20.GL_TEXTURE2);
    GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, mVTextureHandle[0]);
    GLES20.glDeleteTextures(1, mVTextureHandle, 0);
    GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, 0);
Charming
  • 133
  • 1
  • 7
  • The kernel's gralloc implementation seems to be having trouble mapping memory in the client, e.g. `ion: Failed to map memory in the client: Out of memory`. Perhaps you're running out of virtual address space in the process? (See e.g. http://stackoverflow.com/questions/30180268/) – fadden Feb 18 '16 at 16:59
  • correct way of generating textures, Generate: mYTextureHandle = new int[3]; GLES20.glGenTextures(3, mYTextureHandle); Delete: GLES20.glDeleteTextures(3, mYTextureHandle); – DanP Feb 19 '16 at 03:23
  • How big is VIDEO_WIDTH and VIDEO_HEIGHT, and what's the device? Have you used up a big chunk of the virtual address space already by memory mapping a large video file? Aren't the planes in YUV supposed to be 8bpp each, not 32bpp? Could save a lot of memory by using something more appropriate than GLES20.GL_RGBA – Columbo Feb 20 '16 at 07:48

0 Answers0