Link to home
Start Free TrialLog in
Avatar of danielj040300
danielj040300

asked on

GDI Resource Leak

The following code causes a memory leak in my app

HBITMAP m_hLogoBMP = LoadBitmap( _Module.m_hInst, MAKEINTRESOURCE( IDB_GENDAC ) );
if( m_hLogoBMP == NULL )
     return false;
HDC m_hLogoDC  = CreateCompatibleDC( NULL );
SelectObject( m_hLogoDC, m_hLogoBMP );

BitBlt( GetDC(), 30, 30, 180, 142, m_hLogoDC, 0 , 0 , SRCAND );

DeleteDC( m_hLogoDC );
DeleteObject( m_hLogoBMP );

If I comment the BitBlt function out I have no resource leak.

Thanks
Daniel.
ASKER CERTIFIED SOLUTION
Avatar of AlexVirochovsky
AlexVirochovsky

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of danielj040300
danielj040300

ASKER

I only had to call the ReleaseDC(hdc); function.
No more Resource leak!!
Thanks