1 | initial version |
i am not sure but i think memory leak is not causing by "cvInitMatHeader" or "cvConvertImage". i encountered same issue with you and i check the upper two function and nothing seems to make leak. so, i check the others, and i found that memory leak causing by under following code.
SelectObject( hdc, CreateDIBSection( hdc, binfo, DIB_RGB_COLORS, &dst_ptr, 0, 0));
because, created bitmap handle by 'CreateDIBSection' must be deleted after use. but there wasn't.
so, i changed like :
HBITMAP hbitmap = CreateDIBSection(hdc, binfo, DIB_RGB_COLORS, &dst_ptr, 0, 0); h = SelectObject(hdc, hbitmap);
......
and call delete and release function, end of this function.
DeleteObject(hbitmap); ::ReleaseDC(hwnd, hdc); // if not call this will causes few bytes leak every call.
after this everything is fine to me. DIB will be changing by StretchDIBits to DDB and that will be stored to display memory. therefore, after call StretchDIBits the hbitmap can be deleted.