BoundsChecker Resource Leak

I recently ran my source through BoundsChecker to help identify any mem leaks.

It listed my OpenGL window’s HDC as a resource leak. Specifically “Resource Leak Exiting Program” although I verified that ReleaseDC gets called on the way out.

I use the same code for creating and destroying windows and the only one that shows up as a leak is the OpenGL window that I create an RC for (in addition to the DC).

Here is what I am doing:

Create:
hwnd = CreateWindowEx( … )
hdc = GetDC( hwnd )
wglChoosePixelFormatARB
SetPixelFormat
hrc = wglCreateContext
wglMakeCurrent( hdc, hrc )

Exit:
wglMakeCurrent( NULL, NULL )
wglDeleteContext( hrc )
ReleaseDC( hwnd, hdc )

Any clue what I’m missing with this issue?

Thank you.

Hmmm, from what I can see here, everything looks good to me. The problem may not be your code. It could just be BoundsChecker. Programmer’s aren’t always perfect…

Thank you for the quick response. That is what I am beginning to think as well.

I don’t know if this is worth it but,
usually when creating a window and registering a class you would specify to create a private DC for the window(in the RegisterClass call: CS_OWNDC). Even though the WIN32 API docs explicitly says do not delete DC’s retrieved from GetDC this might be a special case. You can try changing ReleaseDC to DeleteDC and see if it makes BoundsChecker happy.

IMHO its bad practice to ignore return values.

So you may want to check if your wgl* calls fail or succeed.

Thank you both for the responses.

roffe: Yes, I always use OWNDC when creating a windows for OpenGL, just to be safe. I’ll try the Delete DC call.

Honk: I am checking for errors, just didn’t put that in the pseudo code above for simplicity. No wgl errors reported back.

robo

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