This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

SK-TDA4VM: Memory leak when creating picture texture with OpenGL

Part Number: SK-TDA4VM
Other Parts Discussed in Thread: TDA4VM

HI 
I have a problem about the continuous reduction of memory when drawing picture texture in OpenGL.

The following is my test demo program code

void  render()
{
    openglInit();

    printf("drawing begin11 \n");
    bool test = false;
    while (true)
    {
        if (!test)
        {
            test = true;
        }
        else
        {
            glDeleteTextures(1, &testTextures);
            appEglCheckGlError("glDeleteTextures");
            printf("glGetError end   %d \n", glGetError());
        }
        createTextures("parktype/parkout_n.png", APA_MODE_PARKOUT_N, true, true);
        glBindFramebuffer(GL_FRAMEBUFFER, m_FboID);
        glViewport(0, 0, SCR_WIDTH, SCR_HEIGHT);
        glClearColor(0.0f, 0.0f, 0.0f, 1.0f);
        glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
        glEnable(GL_DEPTH_TEST);
        Draw(); 
        printf("drawing begin %d \n", test11);
        test11++;
        glBindFramebuffer(GL_FRAMEBUFFER, 0);
        glFinish();
        appEglCheckGlError("glFinish");
        appEglSwap(egl_win_obj);
        app_process_display_graph();
        sleep(1);
    }
    destroyResource();
    return NULL;
}


void createTextures(char *filename, int pic_id)
{
    //---------
    int width, height, nrChannels;
    glGenTextures(1, &testTextures);
    glBindTexture(GL_TEXTURE_2D, testTextures);
    // set the texture wrapping parameters
    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);    // set texture wrapping to GL_REPEAT (default wrapping method)
    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
    // set texture filtering parameters
    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR);
    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
    unsigned char *data = stbi_load(filename, &width, &height, &nrChannels, 0);
    if (data)
    {
        glEnable(GL_BLEND);
        glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
        // note that the awesomeface.png has transparency and thus an alpha channel, so make sure to tell OpenGL the data type is of GL_RGBA
        glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, width, height, 0, GL_RGBA, GL_UNSIGNED_BYTE, data);
        glGenerateMipmap(GL_TEXTURE_2D);
    }
    else
    {
        ALOGD("apa createTextures fail, path is %s", path);
    }
    stbi_image_free(data); 
    glBindTexture(GL_TEXTURE_2D, 0);
}

void Draw()
{
    ourShader.use();
    glActiveTexture(GL_TEXTURE0);
    glBindTexture(GL_TEXTURE_2D, testTextures);
    glBindVertexArray(VAOs[screenStatus]); // seeing as we only have a single VAO there's no need to bind it every time, but we'll do so to keep things a bit more organized
    glDrawElements(GL_TRIANGLES, 6, GL_UNSIGNED_INT, 0);
    glBindTexture(GL_TEXTURE_2D, 0);
}

void destroyResource(){
    ourShader.deleteID();
    deleteTextureAll();
    glDeleteFramebuffers(1, m_FboID);
    glDeleteVertexArrays(2, VAOs);
    glDeleteBuffers(1, EBO0);
    glDeleteBuffers(1, EBO1);
    appEglWindowClose(egl_win_obj);
}
I repeatedly created and deleted textures, and found that the memory was not released after deleting textures, resulting in the continuous reduction of existing in the system.
After that, when the program starts, I create 20 textures at one time, then draw them, delete all textures after 20s, and exit the program, and the memory is not released.
So, where is this part of memory? When will it be released?
Why doesn't my PC test program have this problem?
Is this ti's handling of GPU?
I also found that in the process of creating and deleting textures, when the free memory reaches about 700m, I delete textures again and create textures (delete multiple textures and create fewer textures). I found that the memory is released at this time.
However, only the memory of the current operation is released. After the program exits, the memory is not recycled as a whole, which is still about 700m.
I hope people who know this can help me solve it.
thanks