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…

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.

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);

This topic was automatically closed 183 days after the last reply. New replies are no longer allowed.