Creating large DIB's using CreateDIBSection and CreateFileMapping
-
I have a situation where users are trying to create large 24bit DIBs (10,000 x 10,000) or greater and CreateDIBSection is failing. The problem appears to occur when virtual memory gets low. I can create the large DIBs when I don't have a lot of memory allocated for other things. I tried using the following: HANDLE hFileMap = CreateFileMapping( INVALID_HANDLE_VALUE, NULL, PAGE_READWRITE, 0, dwStorageSize,NULL); dwLE = GetLastError(); if(INVALID_HANDLE_VALUE == hFile) hFile = NULL; if( NULL == hFileMap) ErrMsg( dwLE); LPVOID pDibBits = NULL; HBITMAP hBitmap = ::CreateDIBSection( NULL, m_bitmapinfo, DIB_RGB_COLORS, pDibBits, hFileMap, 0); dwLE = GetLastError(); The thought was that using CreateFileMapping() to allowcate memory for the DIB bits when memory was low but it still fails and GetLastError() return 0 which does not help. Is there a way to use swap file or temporary disk files as storage space for DIB bits when processing large bitmap files?
-
I have a situation where users are trying to create large 24bit DIBs (10,000 x 10,000) or greater and CreateDIBSection is failing. The problem appears to occur when virtual memory gets low. I can create the large DIBs when I don't have a lot of memory allocated for other things. I tried using the following: HANDLE hFileMap = CreateFileMapping( INVALID_HANDLE_VALUE, NULL, PAGE_READWRITE, 0, dwStorageSize,NULL); dwLE = GetLastError(); if(INVALID_HANDLE_VALUE == hFile) hFile = NULL; if( NULL == hFileMap) ErrMsg( dwLE); LPVOID pDibBits = NULL; HBITMAP hBitmap = ::CreateDIBSection( NULL, m_bitmapinfo, DIB_RGB_COLORS, pDibBits, hFileMap, 0); dwLE = GetLastError(); The thought was that using CreateFileMapping() to allowcate memory for the DIB bits when memory was low but it still fails and GetLastError() return 0 which does not help. Is there a way to use swap file or temporary disk files as storage space for DIB bits when processing large bitmap files?
Its not a question of having enough RAM, you need to have enough address space available in your process. I think you won't have this issue on a 64 bit OS and a 64 bit process. Even a 32 bit process on a 64 bit OS helps as long as the process is Large Address Aware.