I don't know but I found this in the comments on the MSDN page for CreateCompatibleBitmap():
Windows apparently may enforce systemwide limits on available memory for CreateCompatibleBitmap. (According to some sources, this is because device-dependent bitmaps must reside in video card RAM.) If you're getting ERROR_NOT_ENOUGH_MEMORY errors when calling CreateCompatibleBitmap, the solution is to use device-independent bitmaps (DIBs) instead.