cancel
Showing results for 
Search instead for 
Did you mean: 

OpenGL & Vulkan

Renardjojo
Journeyman III

High memory usage (leak ?) when moving window

Hello !
I am using glfw for an application that needs to stay open for a long time but this application is leaking.
After some research, I saw that the leak was coming from the "glfwSetWindowPos" function.
I made a quick example to illustrate the memory leak:

 

#include <windows.h>
#include <GLFW/glfw3.h>
#include <cmath>

int CALLBACK WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR pCmdLine, int nCmdShow)
{
    int  frame = 0;

    if (!glfwInit()) exit(-1);

    GLFWwindow* window = glfwCreateWindow(500, 500, "Leak", NULL, NULL);
    glfwMakeContextCurrent(window);
    glfwShowWindow(window);

    while (!glfwWindowShouldClose(window))
    {
        glfwPollEvents();
        frame += 1;
        glfwSwapBuffers(window);
        glfwSetWindowPos(window, std::cos(frame / 100.f) * 50.f, std::sin(frame / 100.f) * 50.f);
    }
    return 0;
}

 

 

 After 5 minutes, my application allocated 25MB in RAM. 10 minutes later, 50MB was allocated for the above code example.
I tested directly on a release build (run with .exe).
I ran the application on Windows 11.

190223377-6946367d-70f6-4188-999a-53c36050865b.png

Based on Visual Leak Detector, it seems to be a memory allocation (not a memory leak) with std::vector behaviour:

190247347-d4b2cb7b-5935-48a0-ba16-ab03c26878e4.png

Based on the call stack, AMD driver seems to be the issue of this leak, but I can't investigate more with my current skills:

Here are my driver details:

Renardjojo_2-1664453652563.png

Is somebody can confirm the issue or have a solution ?

0 Likes
1 Solution
dipak
Big Boss

Thanks for reporting it. I have whitelisted you and moved the post to the OpenGL forum.

From the above driver information, it looks like an old driver. Please try the latest driver available here:

https://www.amd.com/en/support/apu/amd-ryzen-processors/amd-ryzen-7-mobile-processors-radeon-graphic...

https://www.amd.com/en/support/kb/release-notes/rn-rad-win-22-9-2

Thanks.

View solution in original post

0 Likes
2 Replies
dipak
Big Boss

Thanks for reporting it. I have whitelisted you and moved the post to the OpenGL forum.

From the above driver information, it looks like an old driver. Please try the latest driver available here:

https://www.amd.com/en/support/apu/amd-ryzen-processors/amd-ryzen-7-mobile-processors-radeon-graphic...

https://www.amd.com/en/support/kb/release-notes/rn-rad-win-22-9-2

Thanks.

0 Likes
Renardjojo
Journeyman III

Thank you very much, this definitely solved my problem.

0 Likes