MFC屏幕监控程序中 CPaintDC dc(this)运行出错

在屏幕监控程序中,收到BITMAPINFO调色板信息后,代码如下:

m_hDC = ::GetDC(m_hWnd);
m_hMemDC = CreateCompatibleDC(m_hDC);

m_hFullBitmap = NULL;
LPVOID m_lpScreenDIB = NULL;

//CreateDIBSection运行后提示0x00000008not enough storage is availabke to process this command
m_hFullBitmap = CreateDIBSection(m_hDC, m_lpbmi, DIB_RGB_COLORS, &m_lpScreenDIB, NULL, NULL);
(HBITMAP)SelectObject(m_hMemDC, m_hFullBitmap);

当收到传过来的屏幕信息后:

memcpy(m_lpScreenDIB, recvbuf, m_lpbmi->bmiHeader.biSizeImage);
OnPaint();

Debug运行到OnPaint()中的CPaintDC dc(this)这句时弹框提示unhandle exception in exe:0xC0000005:Access violation。程序定位到m_pHashTable == NULL这一句,如下:

void* CMapPtrToPtr::GetValueAt(void* key) const
// find value (or return NULL -- NULL values not different as a result)
{
    if (m_pHashTable == NULL)
        return NULL;
        ......

Release方式运行时,第一次运行没问题,第二次程序就崩溃,一直找不到问题所在,大家帮忙看看

m_hMemDC返回什么,是不是gdi资源不足?有没有没有释放的gdi资源,位图是否过大?