Part of the Khronos Group
OpenGL.org

The Industry's Foundation for High Performance Graphics

from games to virtual reality, mobile phones to supercomputers

Results 1 to 3 of 3

Thread: Why the Memory Leak 4K under SwapBuffers(hDC);?

  1. #1
    Junior Member Newbie
    Join Date
    May 2013
    Posts
    3

    Why the Memory Leak 4K under SwapBuffers(hDC);?

    Hello everyone, my program is developed by opengl under Windows XP,while it rises 4K memory leak when I use SwapBuffers on Paint function.I dont't know why, I has tested so many program(developed by opengl) under XP, but most of them has the same program.
    I wonder whether there is someone flag that must to be setted by OpenGL function to clear the double buffers but I hasn't set it!
    Help...

  2. #2
    Senior Member OpenGL Pro
    Join Date
    Jan 2007
    Posts
    1,217
    Are you quite sure that this is a memory leak? Your GL driver may be doing some internal allocations of it's own and for it's own purposes - does this happen for every call to SwapBuffers or does it happen just once (or a few times) and then settle down? It would be highly unusual for a SwapBuffers call to leak 4k every time - at 60fps that would mean that after 16 seconds running it's leaked almost 4mb; after 1 hour it's getting close to leaking 1gb - which would seriously inconvenience Quake players all over the world (and be even more of an inconvenience to CAD users who may leave their program running all day).

    In other words, if this was an actual real problem that applied to most OpenGL drivers, it would have been noticed and dealt with a long time ago. Maybe you have a driver bug and you just need to update your drivers? Or maybe your code is at fault (if you're doing a GetDC in your WM_PAINT you may not be doing a ReleaseDC, or similar)? Or maybe it's just not a leak at all and is what I described in my first paragraph.

  3. #3
    Junior Member Newbie
    Join Date
    May 2013
    Posts
    3
    Thanks for your reply, Yes, Maybe it's not a memory leak.My Graphics Card is NVIDIA, yesterday I updated my driver, but the problem still existed.And last night I test the program on win7 in my bedroom(different computer), the memory didn't rise.So the problem mybe the GL drivers!

    "if you're doing a GetDC in your WM_PAINT you may not but doing a ReleaseDC, or similar?"
    I have doing a ReleaseDC, but it's nessory doing like GetDC and then ReleaseDC in a for loop:
    while(!eixt)
    {
    ....
    HDC hDC = GetDC(hWnd);
    Render();
    SwapBuffers(hDC);
    ReleaseDC(hWnd, hDC);
    }
    my code is written by following:
    HDC hDC = GetDC(hWnd);
    while(!eixt)
    {
    ....
    Render();
    SwapBuffers(hDC);
    }
    ReleaseDC(hWnd, hDC);

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •