PDA

View Full Version : OpenGL memory leak on Nvidia card



_Coder
10-05-2016, 05:15 AM
Hi
I'am programming multiple window application with two threads. First is render thread and the second is GUI. There is only one opengl context on render thread. On intel cards everything is correct, but on nvidia there is huge memory leak when I create and close window.

Render:


mWindowsCriticalSection.enter();
for (auto window : mWindows)
{
wglMakeCurrent(window.second->getHdc(), mContext);
//only swap buffers
SwapBuffers(window.second->getHdc());
wglMakeCurrent(0, 0);
}
mWindowsCriticalSection.leave();

Window creation:


mHwnd = CreateWindow(
WINDOW_CLASS, mTitle.c_str(),
WS_OVERLAPPEDWINDOW,
400, 400,
400, 400, NULL, NULL,
GetModuleHandle(NULL), NULL);
SetWindowLong(mHwnd, GWLP_USERDATA, (long)this);
mHdc = GetDC(mHwnd);
PIXELFORMATDESCRIPTOR pfd;
int pixelFormat = Renderer::getInstance().getPixelFormat();
DescribePixelFormat(mHdc, pixelFormat, sizeof(pfd), &pfd);
SetPixelFormat(mHdc, pixelFormat, &pfd);
WindowsContainer::getInstance().addWindow(shared_f rom_this());


In WM_DESTROY:


ReleaseDC(mHwnd, mHdc);


This memory leak causes DrvPresentBuffers crash after 20-30 creations and destroys of window.

Any ideas?